Arduino Traffic Lights

For this challenge we will create a traffic lights using an Arduino device/board and three LEDs.

We will use C/C++ to create the code to control the Arduino board to reproduce a following traffic lights sequence:
traffic-light-sequence

You do not need to have access to an Arduino board. Instead you can use the online Arduino simulator from Tinkercad to recreate the electronic circuit and add the code provided below.

Open Tinkercad in new window

Electronic Circuit


First you will need to recreate the following electronic circuit:
arduino-traffic-light

C/C++ Code


Then you will need to use the following code (When using tinkerpad, choose the text option rather than blocks)

Lego Traffic Ligths


If you have access to an Arduino board you can create your own traffic lights and you can plug your LEDs on a breadboard or use lego bricks to create your traffic lights.
lego-traffic-light-frontlego-traffic-light-backlego-led

LEDYou will need:

  • 1 arduino board
  • 1 breadboard
  • 3 resistors (220Ω)
  • 3 LEDs (Red, Organe/Yellow, Green)

Make sure that you always connect the cathode of the LED (short leg, flat edge of the LED) to a black wire.

Share Button