Everyone must have seen those big lights in red, yellow, and green color at the corner of every road. Some even flash. Some stay lit all day long.
Big junctions have a separate controller which synchronizes these lights. So that the traffic flows smoothly. And the possibility of having a deadlock is minimized. That is very complex and requires a deep understanding of road traffic and human perception.
To make a simple traffic light. You will require three LED in RED, Yellow, and Green color.
Components Required:
Arduino
Red 5mm LED
Yellow 5mm LED
Green 5mm LED
330-ohm resistor
Jumper wires
Breadboard small
Arduino Code
#define red 8
#define yellow 7
#define green 4
void setup()
{
pinMode(red, OUTPUT);
pinMode(yellow, OUTPUT);
pinMode(green, OUTPUT);
}
void loop()
{
digitalWrite(green, HIGH);
delay(10000); // Wait for 10 second(s)
digitalWrite(green, LOW);
digitalWrite(yellow, HIGH);
delay(4000); // Wait for 4 second(s)
digitalWrite(yellow,LOW);
digitalWrite(red, HIGH);
delay(5000);
digitalWrite(red,LOW);
}
Leave a Reply