The Traffic count down demonstration using Arduino Mega 2560
Due to its many number of pins then it is easy to implement
---------------------------------------------------------------------------------------------------
Codes
void setup() {
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);
pinMode(12, OUTPUT);pinMode(13, OUTPUT);pinMode(14, OUTPUT);pinMode(15, OUTPUT);pinMode(16, OUTPUT);pinMode(17, OUTPUT);pinMode(18, OUTPUT);pinMode(19, OUTPUT);
pinMode(20, OUTPUT);pinMode(21, OUTPUT);pinMode(22, OUTPUT);pinMode(23, OUTPUT);pinMode(24, OUTPUT);pinMode(25, OUTPUT);pinMode(26, OUTPUT);pinMode(27, OUTPUT);
pinMode(28, OUTPUT);pinMode(29, OUTPUT);pinMode(30, OUTPUT);pinMode(31, OUTPUT);
}
void loop() {
digitalWrite(19, LOW);digitalWrite(35, LOW);digitalWrite(43, LOW);digitalWrite(27, LOW); //TO TURN SEGMENTS TRAFFIC
delay(10);
digitalWrite(20, LOW);digitalWrite(21, LOW);digitalWrite(22, LOW);digitalWrite(23, LOW);digitalWrite(24, LOW);digitalWrite(25, LOW);digitalWrite(26, HIGH); //0 SET
digitalWrite(7, LOW);digitalWrite(10, LOW);
digitalWrite(1, LOW);digitalWrite(4, LOW);
digitalWrite(0, HIGH);digitalWrite(3, HIGH);
digitalWrite(8, HIGH);digitalWrite(11, HIGH);
digitalWrite(28, HIGH);
digitalWrite(31, HIGH);
count_1(); //+DELAY
digitalWrite(28, LOW);
digitalWrite(31, LOW);
//delay(5000);
digitalWrite(19, HIGH);digitalWrite(27, HIGH);digitalWrite(35, HIGH);digitalWrite(43, HIGH); //TO TURN SEGMENTS TRAFFIC
delay(10);
digitalWrite(0, LOW);digitalWrite(3, LOW);
digitalWrite(8, LOW);digitalWrite(11, LOW);
digitalWrite(7, HIGH);digitalWrite(10, HIGH);
digitalWrite(1, HIGH);digitalWrite(4, HIGH);
delay(1000);
digitalWrite(19, LOW);digitalWrite(35, LOW);digitalWrite(43, LOW);digitalWrite(27, LOW); //TO TURN SEGMENTS TRAFFIC
delay(10);
digitalWrite(7, LOW);digitalWrite(10, LOW);
digitalWrite(1, LOW);digitalWrite(4, LOW);
digitalWrite(6, HIGH);digitalWrite(9, HIGH);
digitalWrite(2, HIGH);digitalWrite(5, HIGH);
digitalWrite(29, HIGH);
digitalWrite(30, HIGH);
count_2(); //+DELAY
digitalWrite(29, LOW);
digitalWrite(30, LOW);
digitalWrite(19, HIGH);digitalWrite(27, HIGH);digitalWrite(35, HIGH);digitalWrite(43, HIGH); //TO TURN SEGMENTS TRAFFIC
delay(10);
digitalWrite(2, LOW);digitalWrite(5, LOW);
digitalWrite(6, LOW);digitalWrite(9, LOW);
digitalWrite(7, HIGH);digitalWrite(10, HIGH);
digitalWrite(1, HIGH);digitalWrite(4, HIGH);
delay(1000);
}
// COUNT DOWN FUNCTIONS C_1 & C_2
void count_1(){
digitalWrite(12, LOW);digitalWrite(13, LOW);digitalWrite(14, LOW);digitalWrite(15, LOW);digitalWrite(16, HIGH);digitalWrite(17, LOW);digitalWrite(18, LOW);delay(500);
digitalWrite(12, LOW);digitalWrite(13, LOW);digitalWrite(14, LOW);digitalWrite(15, LOW);digitalWrite(16, LOW);digitalWrite(17, LOW);digitalWrite(18, LOW);delay(500);
digitalWrite(12, LOW);digitalWrite(13, LOW);digitalWrite(14, LOW);digitalWrite(15, HIGH);digitalWrite(16, HIGH);digitalWrite(17, HIGH);digitalWrite(18, HIGH);delay(500);
digitalWrite(12, LOW);digitalWrite(13, HIGH);digitalWrite(14, LOW);digitalWrite(15, LOW);digitalWrite(16, LOW);digitalWrite(17, LOW);digitalWrite(18, LOW);delay(500);
digitalWrite(12, LOW);digitalWrite(13, HIGH);digitalWrite(14, LOW);digitalWrite(15, LOW);digitalWrite(16, HIGH);digitalWrite(17, LOW);digitalWrite(18, LOW);delay(500);
digitalWrite(12, HIGH);digitalWrite(13, LOW);digitalWrite(14, LOW);digitalWrite(15, HIGH);digitalWrite(16, HIGH);digitalWrite(17, LOW);digitalWrite(18, LOW);delay(500);
digitalWrite(12, LOW);digitalWrite(13, LOW);digitalWrite(14, LOW);digitalWrite(15, LOW);digitalWrite(16, HIGH);digitalWrite(17, HIGH);digitalWrite(18, LOW);delay(500);
digitalWrite(12, LOW);digitalWrite(13, LOW);digitalWrite(14, HIGH);digitalWrite(15, LOW);digitalWrite(16, LOW);digitalWrite(17, HIGH);digitalWrite(18, LOW);delay(500);
digitalWrite(12, HIGH);digitalWrite(13, LOW);digitalWrite(14, LOW);digitalWrite(15, HIGH);digitalWrite(16, HIGH);digitalWrite(17, HIGH);digitalWrite(18, HIGH);delay(500);
digitalWrite(12, LOW);digitalWrite(13, LOW);digitalWrite(14, LOW);digitalWrite(15, LOW);digitalWrite(16, LOW);digitalWrite(17, LOW);digitalWrite(18, HIGH);delay(500);
}
void count_2(){
digitalWrite(20, LOW);digitalWrite(21, LOW);digitalWrite(22, LOW);digitalWrite(23, LOW);digitalWrite(24, HIGH);digitalWrite(25, LOW);digitalWrite(26, LOW);delay(500);
digitalWrite(20, LOW);digitalWrite(21, LOW);digitalWrite(22, LOW);digitalWrite(23, LOW);digitalWrite(24, LOW);digitalWrite(25, LOW);digitalWrite(26, LOW);delay(500);
digitalWrite(20, LOW);digitalWrite(21, LOW);digitalWrite(22, LOW);digitalWrite(23, HIGH);digitalWrite(24, HIGH);digitalWrite(25, HIGH);digitalWrite(26, HIGH);delay(500);
digitalWrite(20, LOW);digitalWrite(21, HIGH);digitalWrite(22, LOW);digitalWrite(23, LOW);digitalWrite(24, LOW);digitalWrite(25, LOW);digitalWrite(26, LOW);delay(500);
digitalWrite(20, LOW);digitalWrite(21, HIGH);digitalWrite(22, LOW);digitalWrite(23, LOW);digitalWrite(24, HIGH);digitalWrite(25, LOW);digitalWrite(26, LOW);delay(500);
digitalWrite(20, HIGH);digitalWrite(21, LOW);digitalWrite(22, LOW);digitalWrite(23, HIGH);digitalWrite(24, HIGH);digitalWrite(25, LOW);digitalWrite(26, LOW);delay(500);
digitalWrite(20, LOW);digitalWrite(21, LOW);digitalWrite(22, LOW);digitalWrite(23, LOW);digitalWrite(24, HIGH);digitalWrite(25, HIGH);digitalWrite(26, LOW);delay(500);
digitalWrite(20, LOW);digitalWrite(21, LOW);digitalWrite(22, HIGH);digitalWrite(23, LOW);digitalWrite(24, LOW);digitalWrite(25, HIGH);digitalWrite(26, LOW);delay(500);
digitalWrite(20, HIGH);digitalWrite(21, LOW);digitalWrite(22, LOW);digitalWrite(23, HIGH);digitalWrite(24, HIGH);digitalWrite(25, HIGH);digitalWrite(26, HIGH);delay(500);
digitalWrite(20, LOW);digitalWrite(21, LOW);digitalWrite(22, LOW);digitalWrite(23, LOW);digitalWrite(24, LOW);digitalWrite(25, LOW);digitalWrite(26, HIGH);delay(500);
}
------------------------------------------------------------------------------------------------