// A TRAFFIC LIGHT SYSTEM!!! by: Victoria Omega Gondwe
//Assigning the LED lights to their respective digital pins:
int Red=13;
int Yellow=12;
int Green=11;
//Initializing the digital pins as outputs through the assigned LED lights
void setup() {
pinMode(Red, OUTPUT);
pinMode(Yellow, OUTPUT);
pinMode(Green, OUTPUT);
}
//declaring a function to change the lights in a loop of 1 minute, 25 seconds
void loop(){
changeLights();
}
//Controlling the sequence of the system by calling the above declared function and then defining it.
void changeLights() {
//The Red light(STOP) sequence
//The loop will start with the Red light on, Cars will stop for 30 seconds while the Yellow and Green lights are off
digitalWrite(Red,HIGH );
delay(25000);
//The Yellow light(READY) sequence
//The Red light will go off, Yellow will turn on 10 seconds and Cars will now get ready to GO
digitalWrite(Red,LOW );
digitalWrite(Yellow,HIGH );
delay(10000);
//The Green light(GO) sequence
//The Yellow and Red lights will now go off, Green light will turn for a minute(60 seconds) on Cars can now go
digitalWrite(Yellow,LOW );
digitalWrite(Green,HIGH );
delay(40000);
//The Green light will now turn off so that the loop is complete, Then the Red light will turn on.
digitalWrite(Green,LOW );
}