Arduino Traffic light design

Arduino Traffic light design

949
0
SHARE

We have already completed the small led lighting experiment in the previous blog Arduino Uno LED Flash. In this experiment we will be working on Arduino Uno LED Lights three different color led and with different patterns. We use digital I/O pins to control led blinking using delay function.

Components Required:

Red Led – 1pcs

Green Led – 1pcs

Yellow Led – 1pcs

220Ω resistors – 3pcs

Breadboard – 1pcs

Jumper wires

Arduino Boards

Arduino connection diagram

arduino traffic light

Reference Code :

int redled =10; //Definition digital 8 Interface

int yellowled =7; //Definition digital 7 Interface

int greenled =4; //Definition digital 4 Interface

void setup()

{

pinMode(redled, OUTPUT); //The definition of red light interface as output

pinMode(yellowled, OUTPUT); //The definition of a small red light interface as output

pinMode(greenled, OUTPUT); //The definition of a small green light interface as output

}

void loop()

{

digitalWrite(greenled, HIGH);////Green lights

delay(5000);//Delay 5 seconds

digitalWrite(greenled, LOW); //Green light goes OFF

for(int i=0;i<3;i++)//Alternately flashes three times, flashing yellow light effect

{

delay(500);//Delay 0.5 seconds

digitalWrite(yellowled, HIGH);//Yellow lights

delay(500);//Delay 0.5 seconds

digitalWrite(yellowled, LOW);//Yellow light goes OFF

}

delay(500);//Delay 0.5 seconds

digitalWrite(redled, HIGH);//Red lights

delay(5000);//Delay 5 seconds

digitalWrite(redled, LOW);//Red light goes OFF

}

NO COMMENTS

LEAVE A REPLY