RPi GPIO programming – Tutorial 1: Morse Code Sender

Tutorial 1: Morse Code Sender

Controlling a LED to send a sequence of morse code signals.

Ref: https://gpiozero.readthedocs.io/en/stable/recipes.html

Concepts Covered in this tutorial

  • basic Linux command line operations: mkdir, pwd, ls, cd, cd ~, ssh, nano 
  • introduce python, virtualenv, pip, python library, modules, packages
  • electronic signal in a nutshell (on/off, 1/0)
  • light signal in a nutshell  (from WWI navy signal light to high speed broadband internet)
  • python data structure: dictionary, list; function def, main

What you need?

  • a working Raspberry Pi( short as RPi) with Raspbian OS* .
  • 40 pin GPIO head that soldered to the Rpi, if you use RPi Zero W
  • a LED

*Raspbian OS is basically an Ubuntu Linux operating system. There are tutorials takes you through the installation process.

Make note of the ip address of your RPi. This ip address is the address that you where you send instructions from your working computer to reach RPi.

Enable ssh (Secure Shell) on RPi

In the future we will connect to the RPi use ssh over wifi network from your working computer. You don’t need monitor, dedicate keyboard and mouse. Hooray! 

SSH is a cryptographic network protocol,  it let us open a secured tunnel to send and receive signals and instructions to another computer on the network. In this case the network is your home WIFI. Still, we don’t want anyone else to poke into the communication between the working computer and the RPi.

SSH is a bit similar to https. You must have noticed it when visiting some websites, such like facebook, email or banking website. https is another secure communication protocol which secures your web browser communication to these websites that contains your personal information.

enable ssh on RPi

On Rpi, open a terminal console and type:

sudo raspi-config  [return]


*note: What in the ‘[]’ is an operation – [return] means to press return key.

For Windows users, install a command shell – Putty


This command shell is the console that you will use to launch ssh.

You can install putty (http://www.putty.org/).

For Mac Users you are all good to go

You will use a terminal console comes with Mac – I use a 3rd party terminal tool – iterm2

If your Mac doesn’t have ssh installed, you need to install it via home brew*.