Traffic Light

In this project, we are looking for the case of four traffic lights. The traffic light system which we have designed here is working on the basis or Arduino Uno, a microcontroller which we could program according to our needs.

  The software we use here is  Arduino IDE, which is an open-source programing software, where we could type the programming according to our needs. The program for the above traffic light circuit is,

 

 void setup() {

  // configure the output pins

  pinMode(0,OUTPUT); 

  pinMode(1,OUTPUT);

  pinMode(2,OUTPUT);

  pinMode(3,OUTPUT);

  pinMode(4,OUTPUT);

  pinMode(5,OUTPUT);

  pinMode(6,OUTPUT);

  pinMode(7,OUTPUT);

  pinMode(8,OUTPUT);

  pinMode(9,OUTPUT);

  pinMode(10,OUTPUT);

  pinMode(11,OUTPUT); 

}

 

void loop() 

{

  digitalWrite(0,0); //enables the 1st set of signals

  digitalWrite(1,0);

  digitalWrite(2,1);

  digitalWrite(3,0);

  digitalWrite(4,0);  

  digitalWrite(5,1);

  digitalWrite(6,0);

  digitalWrite(7,0);

  digitalWrite(8,1);

  digitalWrite(9,1);

  digitalWrite(10,0);

  digitalWrite(11,0);

  delay(5000);

 

  digitalWrite(0,0); //yellow 1

  digitalWrite(1,0);

  digitalWrite(2,1);

  digitalWrite(3,0);

  digitalWrite(4,0);  

  digitalWrite(5,1);

  digitalWrite(6,0);

  digitalWrite(7,0);

  digitalWrite(8,1);

  digitalWrite(9,0);

  digitalWrite(10,1);

  digitalWrite(11,0);

  delay(3000);

 

  digitalWrite(0,0); //enables the 2st set of signals

  digitalWrite(1,0);

  digitalWrite(2,1);

  digitalWrite(3,0);

  digitalWrite(4,0);  

  digitalWrite(5,1);

  digitalWrite(6,1);

  digitalWrite(7,0);

  digitalWrite(8,0);

  digitalWrite(9,0);

  digitalWrite(10,0);

  digitalWrite(11,1);

delay(5000);

 

  digitalWrite(0,0); //Yellow 2

  digitalWrite(1,0);

  digitalWrite(2,1);

  digitalWrite(3,0);

  digitalWrite(4,0);  

  digitalWrite(5,1);

  digitalWrite(6,0);

  digitalWrite(7,1);

  digitalWrite(8,0);

  digitalWrite(9,0);

  digitalWrite(10,0);

  digitalWrite(11,1);

  delay(3000); 

   

  digitalWrite(0,0); //enables the 3st set of signals

  digitalWrite(1,0);

  digitalWrite(2,1);

  digitalWrite(3,1);

  digitalWrite(4,0);  

  digitalWrite(5,0);

  digitalWrite(6,0);

  digitalWrite(7,0);

  digitalWrite(8,1);

  digitalWrite(9,0);

  digitalWrite(10,0);

  digitalWrite(11,1);

  delay(5000);

 

  digitalWrite(0,0); //Yellow 3

  digitalWrite(1,0);

  digitalWrite(2,1);

  digitalWrite(3,0);

  digitalWrite(4,1);  

  digitalWrite(5,0);

  digitalWrite(6,0);

  digitalWrite(7,0);

  digitalWrite(8,1);

  digitalWrite(9,0);

  digitalWrite(10,0);

  digitalWrite(11,1);

  delay(3000); 

  digitalWrite(0,1); //enables the 4st set of signals

  digitalWrite(1,0);

  digitalWrite(2,0);

  digitalWrite(3,0);

  digitalWrite(4,0);  

  digitalWrite(5,1);

  digitalWrite(6,0);

  digitalWrite(7,0);

  digitalWrite(8,1);

  digitalWrite(9,0);

  digitalWrite(10,0);

  digitalWrite(11,1);

  delay(5000);

  digitalWrite(0,0); //Yellow 4

  digitalWrite(1,1);

  digitalWrite(2,0);

  digitalWrite(3,0);

  digitalWrite(4,0);  

  digitalWrite(5,1);

  digitalWrite(6,0);

  digitalWrite(7,0);

  digitalWrite(8,1);

  digitalWrite(9,0);

  digitalWrite(10,0);

  digitalWrite(11,1);

  delay(3000);  

}

Close Menu