Morse Code Using Raspberry Pi and LED!

This will get you started with the GPIO pins on the Raspberry Pi, using an API, and, of course, blinking morse code! After you have completed this tutorial, you can for example learn all morse code characters, blink your IP address at startup or blink "Hello, world"!

Step 1: Material You Will Need

To follow this tutorial, you will need:

1x Raspberry Pi (obviously)

1x Breadboard

2x Wires (it is best to use jumper wires to connect to the GPIO pins)

1x Resistor from 270 to 330 Ohm

1x LED

You will get all of this at your hardware store. If you don't find everything, try looking for a different hardware store or buy it online on sites such as Amazon.

Step 2: Building the Circuit

So, now that you have all of the necessary material, let us get to building the actual circuit. First, you have to understand how a breadboard works. A breadboard is used to prototype actual circuits and it is very versatile. On the breadboard, the inside lines connect horizontally and the outside lines, which are called power lines, are connected vertically. If you are confused about the connections, check out the picture with the arrows.

Now that you understand how a breadboard works, let us start:

1. Have a look at the circuit diagram I made.

2. Strip the ends of two pieces of wire (if you have normal wire, not jumper wire).

3. Arrange one end of each wire on both of the inside lines of the breadboard. The left side will be negative and the right positive.

4. Put one end of the resistor on the left (negative) side and make sure it is on the same horizontal line as the stripped end of the soon-to-be negative wire.

5. Put the other end a few holes further down (vertically), on the same horizontal line as your LED will be.

6. Stick it in! Stick the short leg of the LED on the same horizontal line (on the same side) as the end of the resistor and stick the longer leg in another hole across the gap.

7. Put the soon-to-be positive wire on the same horizontal line as the long leg of the LED. Note, right (positive) side of the gap.

8. Boot up your Raspberry Pi

9. Connect the negative wire (left side) to one of the Ground pins (have a look at the image for your respective Raspberry Pi GPIO header)

10. Connect the positive wire (right side) to the Pin #1 to test if your circuit works.

11. The LED will blink! Success! If not, make sure you wired everything correctly and, if it still does not work, ask for help in the comments.

12. Connect your positive wire to GPIO18. We will use this GPIO pin to turn the LED on and off for use with morse code.

13. Don't fret if you did not follow along with everything I said, I have a nice photograph of the finished circuit just for you (look in the Photos)!

Note: If you were wondering about the photos on the Raspberry Pi end, I used some old plastic tube over the wire to make it fit securely onto the RPi headers. Something like a cheap DIY jumper wire!

Step 3: Now for Some Morse Code...

So, we now have successfully made our circuit with our trusty old breadboard and now it is time to dive into the world of morse code! Let us start, shall we?

1. SSH into your Raspberry Pi. To do this:

On Windows: Download and install Putty for Windows. Input the IP address of your Raspberry Pi and, as default, the port for SSH is 22. Finally, click connect and then input the password (standard password is "raspberry").

On Linux: In a terminal, type "ssh -l pi ". Don't be alerted when it asks you to add the host key of the remote host, just type yes, and then input the password (standard password is "raspberry").

2. SSH'd into your Raspberry Pi, type "gpio" to check if the GPIO shell program is there.

3. Clone my Git repository. To do this, type "git clone"

4. Change the directory to Morse_code_RPi. Type "cd Morse_code_RPi"

5. Take a look at sample.c. Type "nano sample.c". Here you can see, well documented, all the functions necessary to setup the gpio shell script and blink numbers. You can also blink IP addresses with the additional help of blinkperiod()!

6. If you want to, you can change the number or the character array to be blinked in morse code. But don't forget to adjust the number of digits (the second argument of "blinknumber()") if you want to change the number!

7. Press Ctrl-X to exit nano.

8. Compile the sample with "gcc -o sample sample.c".

9. Run the sample with "./sample"! So exciting, right?

10. Now, my friend, write down the dots (0.5 seconds long), dashes (1.5 seconds long) and at pauses (1.5 seconds long), begin a new line or write "/".

11. Finally, reference the dots and dashes with the chart above. I know, I know you don't need the chart because you're a pro, am I right?

12. Think of all the cool things you could do with this. For example, you could make your Raspberry Pi automatically blink its IP address or blink "Hello, world" at startup! That would be very cool!

I hope you liked my tutorial and have learned something impressive!

Gangnamstyle137 signing out.



    • Organization Contest

      Organization Contest
    • Build a Tool Contest

      Build a Tool Contest
    • Epilog X Contest

      Epilog X Contest

    8 Discussions


    Question 7 months ago on Step 1

    I want to use the morse code program but I see the hook up is for 3 volts output to led. I want to use 5 volt, to led. What is the set up for this ?


    3 years ago

    Nice, thanks. I will try it on my arduino uno

    3 replies

    Reply 3 years ago

    Do you think it will work? My header file uses the gpio shell program from raspbian


    Reply 3 years ago

    I don't know, I will try one day if I have the time ;)


    Reply 3 years ago

    But you can use the algorithms for digits etc. I used :)


    3 years ago

    I'm always curious how often morse code is used in common life? What is your application for it?

    1 reply

    3 years ago

    My application for it is to blink the IP of the Raspberry Pi at startup, so I know where to connect. Did you know it was or is used in radio between boats as audio?