Lab 1 Ie
Lab 1 Ie
Objective:
To simulate a basic traffic light system using an Arduino and three LEDs (Red, Yellow, and Blue) with
specified time delays to mimic real-world traffic light behavior.
Components Required:
Breadboard
1 x Red LED
1 x Yellow LED
3 x 220-ohm resistors
Jumper wires
Circuit Diagram:
1. Red LED:
o Connect the positive leg (longer) of the Red LED to Digital Pin 9 of the Arduino.
o Connect a 220-ohm resistor between the negative leg (shorter) of the Red LED and the
ground rail on the breadboard.
2. Yellow LED:
o Connect a 220-ohm resistor between the negative leg of the Yellow LED and the ground
rail.
o Connect a 220-ohm resistor between the negative leg of the Blue LED and the ground
rail.
4. Connections to Arduino:
o Connect the ground (GND) of the Arduino to the ground rail of the breadboard.
Code
int red = 9;
int yellow = 8;
int blue = 7;
Observation: void setup(){
pinMode(red, OUTPUT);
Red LED: Lights up for 15 seconds, indicating a
pinMode(yellow, OUTPUT);
stop.
pinMode(blue, OUTPUT);
Yellow LED: Blinks } for a short period, warning
that the signal is void loop(){ about to change.
digitalWrite(red, HIGH);
delay(15000);
digitalWrite(red, LOW);
digitalWrite(yellow, HIGH);
delay(500);
digitalWrite(yellow, LOW);
delay(500);
Blue LED (Green in real-life traffic lights): Stays on for 20 seconds, indicating it's safe to go.