Introduction: Traffic Light - Project 1

In the Instructable, I'll be making a small-scale traffic light using the Arduino Uno. The items required to complete this project are as follows:

  • 4 Red LEDs
  • 4 Yellow LEDs
  • 4 Green LEDs
  • Jumper Wires (x16)
  • 220 (Ohm) Resistors (x12)
  • IR Receiver with Remote
  • Breadboard

I did get some help with the code and how it should work from someone named ADMINISTRATOR on Electronic Hub's website. To see how he made this project, follow this link.

Step 1: Step 1: Adding the LEDs

  1. Add a red, yellow, and green LED to the breadboard.
  2. Connect the smallest lead (short end) of the LEDs to the ground rail using Jumper Wires.
  3. Connect the largest lead (long-bended end) of the LEDs to a 220 (Ohm) Resistor crossing the gap in the breadboard.
  4. Connect the 220 (Ohm) Resistor to the Arduino using a Jumper Wire.
    • Connect the Red LED to Pin 13 on the Arduino.
    • Connect the Yellow LED to Pin 12 on the Arduino.
    • Connect the Green LED to Pin 11 on the Arduino.
  5. Finally, connect a Jumper Wire from the GND rail on the breadboard to the GND pin on the Arduino.

Step 2: Step 2: Adding the Rest of the LEDs

For this step, finish connecting the other 9 LEDs the same way as you did in step 1.

Here's how to connect the LEDs to the Arduino:

  1. For the second set of LEDs:
    • Red = Pin 10
    • Yellow = Pin 9
    • Green = Pin 8
  2. For the Third set of LEDs
    • Red = Pin 7
    • Yellow = Pin 6
    • Green = Pin 5
  3. For the Fourth set of LEDs
    • Red = Pin 4
    • Yellow = Pin 3
    • Green = Pin 2

Step 3: Step 3: Add the IR Receiver

  1. On the IR Receiver, there will be 3 pins labeled "G", "R", and "Y".
  2. Connect the G pin on the IR Receiver to the GND pin on the Arduino
  3. Connect the R pin on the IR Receiver to the 5V pin on the Arduino
  4. Finally, connect the Y pin on the IR Receiver to pin 1 on the Arduino

Step 4: Step 3: Coding the Program

Now for the coding portion. I created the above diagram to assist me with how to build the program along with the help that I mentioned in the intro. In the program, I used an array to set the values for each road or set of LEDs. Logically, I started with the first row of LEDs being Road 1 and so on. I programmed it using the idea that Road 1 and Road 3 should start and stop at the same time and vice-versa for Road 2 and Road 4.

The IR Receiver is used for basic input. In the code the buttons on the remote perform the following task:

  • Power turns all red LEDs on
  • VOL+ turns all green LEDs on
  • Func/Stop turns all yellow LEDs on