Skip to content

Project 1.1.6: TRAFFIC LIGHT

Description This project shows how to make three LEDs turn on and off one after the other using an Arduino Uno. It introduces simple sequencing and timing control.
Use case This project imitates a traffic light system, where different lights turn on in order to guide movement and improve safety.

Components (Things You will need)

LED Arduino Uno Arduino USB Cable Breadboard Jumper Wires ! Resistor

Building the circuit

Things Needed:

  • Arduino Uno = 1
  • Arduino USB cable = 1
  • White LED = 1
  • Red LED = 1
  • Yellow LED = 1
  • Red jumper wires = 1
  • Blue jumper wires = 1
  • Black jumper wires = 1
  • White jumper wires = 1
  • Green jumper wires = 1
  • Purple jumper wires = 1

Mounting the component on the breadboard

Step 1: Place the three LEDs on the breadboard. For each LED, the longer leg is the positive pin, while the shorter leg is the negative pin.

LED fixed on breadboard.

NB: Make sure you identify where the positive pin (+) and the negative pin (-) is connected to on the breadboard. The longer pin of the LED is the positive pin and the shorter one, the negative PIN.

WIRING THE CIRCUIT

Things Needed:

  • jumper wires = 6

Step 2:Connect the positive leg of the first LED to pin 6 on the Arduino through a 220Ω resistor. Connect its negative leg to GND.

LED fixed on breadboard.

Step 3: Connect the positive leg of the second LED to pin 5 on the Arduino through a 220Ω resistor. Connect its negative leg to GND.

LED fixed on breadboard.

Step 4: Connect the positive leg of the third LED to pin 4 on the Arduino through a 220Ω resistor. Connect its negative leg to GND.

LED fixed on breadboard.

make sure you connect the arduino usb use blue cable to the Arduino board.

PROGRAMMING

Step 1: Open your Arduino IDE. See how to set up here: Getting Started.

Step 2: Type the following codes in the void setup function as shown in the image below. ``` pinMode(6, OUTPUT); sets pin 6 as an output pin for the first LED. pinMode(5, OUTPUT); sets pin 5 as an output pin for the second LED. pinMode(4, OUTPUT); sets pin 4 as an output pin for the third LED.

```

LED fixed on breadboard.

NB: pinMode will help the Arduino board to decide which port should be activated. The code below will turn off the three light bulbs.

Step 3: Type the following codes in the void loop function.as shown in the image below; ``` digitalWrite (6, HIGH); delay (1000); digitalWrite (6, LOW); delay (1000);
// this codes above will turn on and of the white LED

digitalWrite (5, HIGH); delay (1000); digitalWrite (5, LOW); delay (1000);
// this codes above will turn on and of the red LED

digitalWrite (4, HIGH); delay (1000); digitalWrite (4, LOW); delay (1000);
// this codes above will turn on and of the yellow LED ``` LED fixed on breadboard.

_NB: To turn this LEDS off, you can change the “HIGH” in the ode into “LOW” _

Step 4: Save your code. See the Getting Started section

Step 5: Select the arduino board and port See the Getting Started section:Selecting Arduino Board Type and Uploading your code.

Step 6: Upload your code. See the Getting Started section:Selecting Arduino Board Type and Uploading your code

CONCLUSION

This project helps learners understand how to control three LEDs in a sequence using Arduino. It is a simple introduction to traffic light systems, timing, and repeated actions.