The use of Arduino in traffic management has become increasingly popular in recent years. Arduino is a microcontroller that allows you to control different components, including LED lights. This tutorial will show you how to control a traffic light using an Arduino.

Required Components

To build a traffic light control system, you will need the following components:

  • Arduino board (Uno or Nano)
  • Breadboard
  • Jumper wires
  • Green, yellow, and red LED lights
  • Resistors (220 ohms)
  • Power source (9V battery or USB cable)

Circuitry

Before assembling the circuitry, connect the LEDs and resistors on the breadboard. The circuitry for the traffic light control system is straightforward. Follow the steps below:

  • Connect the green LED to pin 2 of the Arduino.
  • Connect the yellow LED to pin 3 of the Arduino.
  • Connect the red LED to pin 4 of the Arduino.
  • Connect the 220-ohm resistor to each LED's cathode (short leg).
  • Connect the other end of the resistor to the ground rail on the breadboard.
  • Connect the anode (long leg) of each LED to the power rail on the breadboard.

Programming the Arduino

The next step is to program the Arduino. Here's how you can do it:

  • Open the Arduino IDE on your computer.
  • Create a new sketch and save it.
  • Copy and paste the code below into the sketch.
    void setup() { pinMode(2, OUTPUT);
    pinMode(3, OUTPUT);
    pinMode(4, OUTPUT);
    }

    void loop() {
    digitalWrite(2, HIGH);
    delay(5000);
    digitalWrite(2, LOW);
    delay(1000);
    digitalWrite(3, HIGH);
    delay(2000);
    digitalWrite(3, LOW);
    delay(1000);
    digitalWrite(4, HIGH);
    delay(5000);
    digitalWrite(4, LOW);
    delay(1000);
    }

Assembling the Traffic Light

Now that the circuitry and programming are done, it's time to assemble the traffic light. Follow the steps below:

  • Connect the jumper wires to each LED and to the corresponding pin on the Arduino board.
  • Place the Arduino board on the breadboard.
  • Connect the power source to the breadboard.
  • Turn on the power source.

Testing the Traffic Light

To test the traffic light, the LED lights should change colors in the following order:

  • Green for 5 seconds
  • Yellow for 2 seconds
  • Red for 5 seconds

If the LED lights do not change colors in the correct sequence, check the circuitry and programming. You can also use the serial monitor in the Arduino IDE to check for errors in the code.

Conclusion

In conclusion, controlling a traffic light using Arduino is a fun and useful project that can teach you a lot about programming and circuitry. With a basic understanding of Arduino, you can easily build your own traffic light control system. Remember to be careful when working with electricity and follow the steps carefully.