const int LeftledPin = 8;
const int RightledPin = 9;
const int buttonPin = 2;
int buttonState = 0;
void setup() {
// put your setup code here, to run once:
pinMode(LeftledPin, OUTPUT);
pinMode(RightledPin, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH){
digitalWrite(LeftledPin, HIGH);
digitalWrite(RightledPin, LOW);
}
else{
digitalWrite(LeftledPin, LOW);
digitalWrite(RightledPin, HIGH);
}
}