/*
Traffic Light
Use pin 4 - 11 to control a two way traffic light 
3 lights on a side 

Output Pin set up 
Robot 2                       Robot 1
Pin 4 =Red                    Pin 8 = Red 
Pin 5 = Amber                 Pin 9 = Amber 
Pin 6 = Green                 Pin 10 = Green
*/

int delay1 = 2000;//Delay for 2 seconds
int delay2 =1000 ;//Delay for 1 second 
void setup() {
DDRD = B11111100; //sets the Aurduino pins 2 to 7 as outputs 
DDRB= B11111111; //sets the Arduino 8 to 13 as outputs 
}

void loop() {
digitalWrite(4, HIGH);//Red Light of Robot 2 On
digitalWrite(10, HIGH);//Green Light of Robot 1 On
digitalWrite(8, LOW);//Red Light of Robot 1 Off
delay(delay1);//Delay for 2 seconds
digitalWrite(10, LOW); //Green Light of Robot 1 Off 
digitalWrite(9 , HIGH);//Yellow ligt of Robot 1 On 
delay(delay2);//Delay for 1 second 
digitalWrite(4 , LOW);//Red Light of Robot 2 off 
digitalWrite(9, LOW);//Yellow ligt of Robot 1 Off
digitalWrite(8 , HIGH);//Red Light of Robot 1 On
digitalWrite(6, HIGH);//Green Light of Robot 2 off
delay(delay1);
digitalWrite(6, LOW);//Green Light of Robot 2 Off
digitalWrite(5, HIGH);//Yellow light of robot 2 On
delay(delay2);
digitalWrite(5, LOW);//Yellow light of robot 2 Off
}