# define Green 11 // port for green LED # define yellow 12 // port for green LED # define Red 13 // port for red LED int no_of_blinks = 3; // number of blinks (configurable) int red_time = 5000; // period for red signal (configurable) int green_time = 6000; // period for green signal (configurable) int yellow_time = 1000; // period for yellow signal (configurable) int blinks = 500; // period of a blink void setup() { pinMode(Green, OUTPUT); // pin declaration as OUTPUT pinMode(yellow, OUTPUT); // pin declaration as OUTPUT pinMode(Red, OUTPUT); // pin declaration as OUTPUT } void loop() { int count_blinks = 0; int count_blink = 0; digitalWrite(Green, LOW); // turn OFF green LED digitalWrite(Red, LOW); // turn OFF red LED digitalWrite(yellow, LOW); // turn OFF yellow LED digitalWrite(Red, HIGH); // turn ON red LED delay(red_time); while (count_blinks <= no_of_blinks) { digitalWrite(Red, HIGH); // keep in ON state red LED delay(blinks); digitalWrite(Red, LOW); // turn ON red LED delay(blinks); count_blinks = count_blinks + 1; } digitalWrite(yellow, HIGH);// turn ON yellow LED delay(yellow_time); digitalWrite(yellow, LOW); // turn OFF yellow LED digitalWrite(Green, HIGH); // turn ON greeb LED delay(green_time); while (count_blink <= no_of_blinks) { digitalWrite(Green, HIGH);// keep in ON state green LED delay(blinks); digitalWrite(Green, LOW); //turn OFF green LED delay(blinks); count_blink = count_blink + 1; } }