Experiment 2: Traffic Light Signal
Objective: Simulate a traffic light signal using an Arduino and LEDs to represent the red, yellow,
and green lights.
Components:
• Arduino UNO R3 DIP
• Breadboard
• Jumper Wire All type
• Red, yellow and green LEDs
• Three 220Ω or 1KΩ Resistors
Steps to Perform the Experiment:
A. Set Up the Hardware
1. Place the LEDs on the Breadboard:
- Insert the red, yellow, and green LEDs into the breadboard. The longer leg (anode) is the positive terminal,
and the shorter leg (cathode) is the negative terminal.
2. Connect the Resistors:
- Place each resistor in series with each LED's anode (longer leg). Connect one end of the resistor to the LED's
anode and the other end to a jumper wire.
3. Connect the LEDs to the Arduino:
- Red LED Anode: Connect the free end of the resistor to DP 9 on the Arduino.
- Yellow LED Anode: Connect the free end of the resistor to DP 10 on the Arduino.
- Green LED Anode: Connect the free end of the resistor to DP 11 on the Arduino.
- Cathodes of all LEDs: Connect to the GND rail on the breadboard.
4. Set Up the Breadboard:
- Connect the Arduino's GND pin to the breadboard's GND rail to complete the circuit.
B. Upload the Code to the Arduino
1. Open the Arduino IDE on your computer.
2. Connect your Arduino UNO to your computer using the USB cable.
3. Write the code into the Arduino IDE.
4. Select the correct board and port in the Arduino IDE (`Tools > Board > Arduino UNO`, `Tools > Port > your
port`).
5. Click the "Upload" button to upload the code to the Arduino.
C. Testing the Setup
1. After uploading the code, the Arduino should start running the program.
2. The green LED should turn on for 5 seconds, representing the "Go" signal.
3. The yellow LED should turn on for 2 seconds, representing the "Caution" signal.
4. The red LED should turn on for 5 seconds, representing the "Stop" signal.
5. The cycle should repeat continuously, simulating a traffic light system.
Robo%cs & A.I. – Class IX | SMC Prayagraj