int swt = 3; int leftled = 2; int rightled = 4; //declares the pins being used. void setup() { pinMode(3, INPUT); pinMode(2, OUTPUT); pinMode(4, OUTPUT); //assigns the pins as inputs/outputs. Serial.begin(9600); // begins communication with the serial monitor. } void loop() Serial.print("Status:"); { if(digitalRead(swt) == 1) //declares a condition that if the switch is pressed. { digitalWrite(leftled, HIGH); // left led is on when switch is pressed Serial.println("LEFT ON"); // sends a message to serial monitor to say the led is on. delay(400); // wait .4 sec. digitalWrite(leftled, LOW); digitalWrite(rightled, HIGH); Serial.print("Status:"); Serial.println("RIGHT ON"); delay(400); digitalWrite(rightled, LOW); } else{ digitalWrite(leftled, LOW); // if switch is not pressed led is off. digitalWrite(rightled, LOW); Serial.println("OFF"); delay(1000); } }