Physical Computing – Traffic lights

Reading Time: 2 minutes

Physical computing in this context means programming and interacting with the real world through electronics. In this mini tutorial we will look a prototyping a simple traffic lights project using the raspberry pi, it will also introduce us to the forty GPIO pins.

What you will need:

  1. Raspberry pi
  2. Resistors 3
  3. LED (Light Emitting Diodes) 3
  4. Bread Board
  5. Connecting Wires (Male to Female, male to male)


GPIO pin configuration
GPIO pin configuration


  1. Connect the resistor to the negative end (Shorter leg)of the LED and the longer leg of the LED to GPIO pins 4, 17, 27
  2. Connect the other end of the resistor to ground, a resistor is required to limit the amount of current being drawn by each LED, to avoid damage to the Pi
  3. Breadboard Continuity is explained and should be understood before making connections
  4. Open your favorite text editor and write the code to control the LEDS
Breadboard Continuity explained
from gpiozero import LED #importing LED class
from time import sleep
red = LED(4)
amber = LED(17)
green = LED(27)


while True:

Credits: Raspberry PI Magpi Magazine

Leave a Reply

Your email address will not be published. Required fields are marked *