Everything you need to set up and run the Morse Code project on your own Raspberry Pi.
Model 3, 4, or 5. Any will work. You'll also need a power supply and a microSD card with Raspberry Pi OS installed.
Required
The official Raspberry Pi Sense HAT add-on board. It plugs directly onto the Pi's GPIO header โ no soldering needed.
RequiredAny standard USB mouse. This is your Morse code input device.
RequiredA monitor or TV with HDMI input to see the fullscreen interface.
RequiredConnected via the 3.5mm audio jack or HDMI. Needed for beep sounds and text-to-speech.
RecommendedFor initial setup and the optional keyboard mode. Not needed for Morse code input.
RecommendedOpen a terminal on your Raspberry Pi and run:
Install the required Python libraries:
This provides a backup text-to-speech engine:
Start the Morse code system:
The application will launch in fullscreen mode. You're ready to start clicking Morse code.
Want the Morse code system to start automatically when you power on the Pi? Run:
This creates a systemd service that launches the application on every boot. To disable it later:
Try spelling "HI" in Morse code to verify everything works:
Click the left mouse button four times quickly. You'll hear four short beeps. Wait 1.5 seconds โ the letter "H" appears on the LED and screen.
Click twice quickly. Wait 1.5 seconds โ "I" appears. Now right-click to complete the message. The Pi will say "Message complete: HI" and play the Mario tune.
Make sure the Sense HAT is firmly seated on the GPIO pins. The system will continue to work without it โ check the HDMI screen for output.
Check your audio output setting with raspi-config. Try both the 3.5mm jack and HDMI output. Make sure the volume is up.
Re-run pip3 install sense-hat pygame pyttsx3 numpy. On some Pi OS versions you may need sudo apt-get install python3-pygame.
The code sets sense.set_rotation(270). If letters appear sideways, try changing this to 0, 90, or 180 in the source code.
Once you have it running, here are some fun ways to make it your own:
Change the LED colours for different letters or add a rainbow mode.
Replace the Mario tune with your own melody. The note format is simple: (frequency, duration).
Add a timer to see how fast you can spell words in Morse code.
Show the Morse code for a random letter and ask the user to input it correctly.
Send Morse code messages between two Raspberry Pis over the network.
Track accuracy, speed, and most-used letters. Display stats on the screen.
Ready to build? Grab the code and start clicking.
โญ View on GitHub