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
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
- Add a red, yellow, and green LED to the breadboard.
- Connect the smallest lead (short end) of the LEDs to the ground rail using Jumper Wires.
- Connect the largest lead (long-bended end) of the LEDs to a 220 (Ohm) Resistor crossing the gap in the breadboard.
- 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.
- 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:
- For the second set of LEDs:
- Red = Pin 10
- Yellow = Pin 9
- Green = Pin 8
- For the Third set of LEDs
- Red = Pin 7
- Yellow = Pin 6
- Green = Pin 5
- For the Fourth set of LEDs
- Red = Pin 4
- Yellow = Pin 3
- Green = Pin 2
Step 3: Step 3: Add the IR Receiver
- On the IR Receiver, there will be 3 pins labeled "G", "R", and "Y".
- Connect the G pin on the IR Receiver to the GND pin on the Arduino
- Connect the R pin on the IR Receiver to the 5V pin on the Arduino
- 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
We have a be nice policy.
Please be positive and constructive.