Mohd Sohail
Published © GPL3+

How to make Traffic Lights using 7 segment Display

Traffic Lights

IntermediateFull instructions provided1 hour714
How to make Traffic Lights using 7 segment Display

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
7 Segment LED Display, InfoVue
7 Segment LED Display, InfoVue
×1
5 mm LED: Red
5 mm LED: Red
×1
5 mm LED: Yellow
5 mm LED: Yellow
×1
5 mm LED: Green
5 mm LED: Green
×1
Resistor 330 ohm
Resistor 330 ohm
×4
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Schematics

Circuit

Code

Arduino Code

Arduino
// https://www.youtube.com/channel/UCaXI2PcsTlH5g0et67kdD6g  //

// Traffic Lights //

// By MOHD SOHAIL //



int led1=2;      // Conncet a resistor of 220 ohms with GND terminal 

int led2=3;

int led3=4;

int led4=5;

int led5=6;

int led6=7;

int led7=8;

int green=11;     // connect 220 ohm resistor with LEDs 

int yellow=12;

int red=13;



void setup() {

 pinMode(led1, OUTPUT);

 pinMode(led2, OUTPUT);

 pinMode(led3, OUTPUT);

 pinMode(led4, OUTPUT);

 pinMode(led5, OUTPUT);

 pinMode(led6, OUTPUT);

 pinMode(led7, OUTPUT);

 pinMode(green, OUTPUT);

 pinMode(yellow, OUTPUT);

 pinMode(red, OUTPUT);

}



void loop() {

 //9 

 digitalWrite(led1,1);

 digitalWrite(led2,1);

 digitalWrite(led3,1);

 digitalWrite(led4,1);

 digitalWrite(led5,0);

 digitalWrite(led6,1);

 digitalWrite(led7,1);

 digitalWrite(green,0);

 digitalWrite(yellow,0);

 digitalWrite(red,1);

 delay(1000);



 //8

 digitalWrite(led1,1);

 digitalWrite(led2,1);

 digitalWrite(led3,1);

 digitalWrite(led4,1);

 digitalWrite(led5,1);

 digitalWrite(led6,1);

 digitalWrite(led7,1);

 digitalWrite(green,0);

 digitalWrite(yellow,0);

 digitalWrite(red,1);

 delay(1000);



 //7

 digitalWrite(led1,1);

 digitalWrite(led2,1);

 digitalWrite(led3,1);

 digitalWrite(led4,0);

 digitalWrite(led5,0);

 digitalWrite(led6,0);

 digitalWrite(led7,0);

 digitalWrite(green,0);

 digitalWrite(yellow,0);

 digitalWrite(red,1);

 delay(1000);



 //6

  digitalWrite(led1,1);

 digitalWrite(led2,0);

 digitalWrite(led3,1);

 digitalWrite(led4,1);

 digitalWrite(led5,1);

 digitalWrite(led6,1);

 digitalWrite(led7,1);

 digitalWrite(green,0);

 digitalWrite(yellow,0);

 digitalWrite(red,1);

 delay(1000);



 //5

  digitalWrite(led1,1);

 digitalWrite(led2,0);

 digitalWrite(led3,1);

 digitalWrite(led4,1);

 digitalWrite(led5,0);

 digitalWrite(led6,1);

 digitalWrite(led7,1);

 digitalWrite(green,0);

 digitalWrite(yellow,0);

 digitalWrite(red,1);

 delay(1000);



 //4

  digitalWrite(led1,0);

 digitalWrite(led2,1);

 digitalWrite(led3,1);

 digitalWrite(led4,0);

 digitalWrite(led5,0);

 digitalWrite(led6,1);

 digitalWrite(led7,1);

 digitalWrite(green,0);

 digitalWrite(yellow,0);

 digitalWrite(red,1);

 delay(1000);



 //3

  digitalWrite(led1,1);

 digitalWrite(led2,1);

 digitalWrite(led3,1);

 digitalWrite(led4,1);

 digitalWrite(led5,0);

 digitalWrite(led6,0);

 digitalWrite(led7,1);

 digitalWrite(green,0);

 digitalWrite(yellow,0);

 digitalWrite(red,1);

 delay(1000);



 //2

  digitalWrite(led1,1);

 digitalWrite(led2,1);

 digitalWrite(led3,0);

 digitalWrite(led4,1);

 digitalWrite(led5,1);

 digitalWrite(led6,0);

 digitalWrite(led7,1);

 digitalWrite(green,0);

 digitalWrite(yellow,0);

 digitalWrite(red,1);

 delay(1000);



 //1

  digitalWrite(led1,0);

 digitalWrite(led2,1);

 digitalWrite(led3,1);

 digitalWrite(led4,0);

 digitalWrite(led5,0);

 digitalWrite(led6,0);

 digitalWrite(led7,0);

 digitalWrite(green,0);

 digitalWrite(yellow,0);

 digitalWrite(red,1);

 delay(1000);

 

 //0

  digitalWrite(led1,1);

 digitalWrite(led2,1);

 digitalWrite(led3,1);

 digitalWrite(led4,1);

 digitalWrite(led5,1);

 digitalWrite(led6,1);

 digitalWrite(led7,0);

 digitalWrite(green,0);

 digitalWrite(yellow,0);

 digitalWrite(red,1);

 delay(1000);



  //4

  digitalWrite(led1,0);

 digitalWrite(led2,1);

 digitalWrite(led3,1);

 digitalWrite(led4,0);

 digitalWrite(led5,0);

 digitalWrite(led6,1);

 digitalWrite(led7,1);

 digitalWrite(green,0);

 digitalWrite(yellow,1);

 digitalWrite(red,0);

 delay(1000);



 //3

  digitalWrite(led1,1);

 digitalWrite(led2,1);

 digitalWrite(led3,1);

 digitalWrite(led4,1);

 digitalWrite(led5,0);

 digitalWrite(led6,0);

 digitalWrite(led7,1);

 digitalWrite(green,0);

 digitalWrite(yellow,1);

 digitalWrite(red,0);

 delay(1000);



 //2

  digitalWrite(led1,1);

 digitalWrite(led2,1);

 digitalWrite(led3,0);

 digitalWrite(led4,1);

 digitalWrite(led5,1);

 digitalWrite(led6,0);

 digitalWrite(led7,1);

 digitalWrite(green,0);

 digitalWrite(yellow,1);

 digitalWrite(red,0);

 delay(1000);



 //1

  digitalWrite(led1,0);

 digitalWrite(led2,1);

 digitalWrite(led3,1);

 digitalWrite(led4,0);

 digitalWrite(led5,0);

 digitalWrite(led6,0);

 digitalWrite(led7,0);

 digitalWrite(green,0);

 digitalWrite(yellow,1);

 digitalWrite(red,0);

 delay(1000);

 

 //0

  digitalWrite(led1,1);

 digitalWrite(led2,1);

 digitalWrite(led3,1);

 digitalWrite(led4,1);

 digitalWrite(led5,1);

 digitalWrite(led6,1);

 digitalWrite(led7,0);

 digitalWrite(green,0);

 digitalWrite(yellow,1);

 digitalWrite(red,0);

 delay(1000);



 //9 

 digitalWrite(led1,1);

 digitalWrite(led2,1);

 digitalWrite(led3,1);

 digitalWrite(led4,1);

 digitalWrite(led5,0);

 digitalWrite(led6,1);

 digitalWrite(led7,1);

 digitalWrite(green,1);

 digitalWrite(yellow,0);

 digitalWrite(red,0);

 delay(1000);



 //8

 digitalWrite(led1,1);

 digitalWrite(led2,1);

 digitalWrite(led3,1);

 digitalWrite(led4,1);

 digitalWrite(led5,1);

 digitalWrite(led6,1);

 digitalWrite(led7,1);

 digitalWrite(green,1);

 digitalWrite(yellow,0);

 digitalWrite(red,0);

 delay(1000);



 //7

 digitalWrite(led1,1);

 digitalWrite(led2,1);

 digitalWrite(led3,1);

 digitalWrite(led4,0);

 digitalWrite(led5,0);

 digitalWrite(led6,0);

 digitalWrite(led7,0);

 digitalWrite(green,1);

 digitalWrite(yellow,0);

 digitalWrite(red,0);

 delay(1000);



 //6

  digitalWrite(led1,1);

 digitalWrite(led2,0);

 digitalWrite(led3,1);

 digitalWrite(led4,1);

 digitalWrite(led5,1);

 digitalWrite(led6,1);

 digitalWrite(led7,1);

 digitalWrite(green,1);

 digitalWrite(yellow,0);

 digitalWrite(red,0);

 delay(1000);



 //5

  digitalWrite(led1,1);

 digitalWrite(led2,0);

 digitalWrite(led3,1);

 digitalWrite(led4,1);

 digitalWrite(led5,0);

 digitalWrite(led6,1);

 digitalWrite(led7,1);

 digitalWrite(green,1);

 digitalWrite(yellow,0);

 digitalWrite(red,0);

 delay(1000);



 //4

  digitalWrite(led1,0);

 digitalWrite(led2,1);

 digitalWrite(led3,1);

 digitalWrite(led4,0);

 digitalWrite(led5,0);

 digitalWrite(led6,1);

 digitalWrite(led7,1);

 digitalWrite(green,1);

 digitalWrite(yellow,0);

 digitalWrite(red,0);

 delay(1000);



 //3

  digitalWrite(led1,1);

 digitalWrite(led2,1);

 digitalWrite(led3,1);

 digitalWrite(led4,1);

 digitalWrite(led5,0);

 digitalWrite(led6,0);

 digitalWrite(led7,1);

 digitalWrite(green,1);

 digitalWrite(yellow,0);

 digitalWrite(red,0);

 delay(1000);



 //2

  digitalWrite(led1,1);

 digitalWrite(led2,1);

 digitalWrite(led3,0);

 digitalWrite(led4,1);

 digitalWrite(led5,1);

 digitalWrite(led6,0);

 digitalWrite(led7,1);

 digitalWrite(green,1);

 digitalWrite(yellow,0);

 digitalWrite(red,0);

 delay(1000);



 //1

  digitalWrite(led1,0);

 digitalWrite(led2,1);

 digitalWrite(led3,1);

 digitalWrite(led4,0);

 digitalWrite(led5,0);

 digitalWrite(led6,0);

 digitalWrite(led7,0);

 digitalWrite(green,1);

 digitalWrite(yellow,0);

 digitalWrite(red,0);

 delay(1000);

 

 //0

  digitalWrite(led1,1);

 digitalWrite(led2,1);

 digitalWrite(led3,1);

 digitalWrite(led4,1);

 digitalWrite(led5,1);

 digitalWrite(led6,1);

 digitalWrite(led7,0);

 digitalWrite(green,1);

 digitalWrite(yellow,0);

 digitalWrite(red,0);

 delay(1000);

}

Credits

Mohd Sohail

Mohd Sohail

10 projects • 4 followers
I'm a Robotics Engineer and Freelancer

Comments