• Raspberry Pi running Raspbian Jessie with display, mouse, keyboard and power source (see Introduction, steps 1-5)
  • Breadboard
  • LED
  • Resistor (50-100 Ohm is good for most LEDs – ask your vendor for a LED + resistor for 3.3V and 20mA )
  • 2 Male-To-Female jumper cables

Assemble the circuit like in the picture below:

LED circuit

LED circuit

Pin 11 (in BOARD numbering) is connected to the positive and pin 6 (ground) to the negative pole of the LED. Boot the Raspberry Pi after assembly- the LED should not light up!

Start the terminal and create a new file with
Fill the file with the following code:

Close Nano and save the file by pressing CTRL + X, then Y. Start the script by typing
The LED now blinks; quit the program by pressing CTRL + C

Code explained
The script uses two libraries: sleep from the time library and the GPIO python interface. They are imported with

Python needs to know which pin numbering applies for the GPIO. This example uses pin 11 in BOARD numbering, which is defined by

Pin 11 could be configured either as input or output. Since an LED should be supplied with power, it has to be setup as output:

For repeated blinking, an endless loop with an always True stop condition is defined:

In the loop, the LED is turned off, then program execution sleeps for half a second:

and turned on again with

Have fun!


Time limit is exhausted. Please reload CAPTCHA.