/*
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
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
led1:A
led1:C
led2:A
led2:C
led3:A
led3:C
led4:A
led4:C
led5:A
led5:C
led6:A
led6:C