[Project 2] – Simple LED Traffic Lights [Beginner Arduino Project]

[PROJECT 2]  In this project we will make an example of traffic lights. I will use arduino mega 2560. You can use the other arduino cards. This project for beginners. Good LuckTraffic Lights

 

Materials:


Arduino Mega 2560 / Other Arduino Cards   x 1
Breadboard    x 1 
220 ohm resistor    x 3
Green LED    x 1
Yellow LED     x 1
Red LED    x 1
Jumper Cable

 

Program:


 // letsarduino.com
// Projet 2 - Traffic Lights

int redLedDelay = 10000;
int greenLedDelay = 10000;
int redLed = 7;
int yellowLed = 6;
int greenLed = 5;

void setup(){
 pinMode(redLed, OUTPUT);
 pinMode(yellowLed, OUTPUT);
 pinMode(greenLed, OUTPUT);
}

void loop(){
 
 digitalWrite(redLed, HIGH);
 delay(redLedDelay);
 
 digitalWrite(yellowLed, HIGH);
 delay(2000);
 
 digitalWrite(redLed, LOW);
 digitalWrite(yellowLed, LOW);
 digitalWrite(greenLed, HIGH);
 delay(greenLedDelay);
 
 digitalWrite(yellowLed, HIGH);
 digitalWrite(greenLed, LOW);
 delay(2000);
 
 digitalWrite(yellowLed, LOW);
 
 }

 

Traffic Lights To Work In This Way:


 

Project Related Images


20141125_21212320141125_21215720141125_212230



 

You may also like...