#define led1 15
#define led2 2
#define btn 4
int btn_state;
int btn_currState;
int led_state = LOW;
void setup() {
Serial.begin(9600);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(btn, INPUT_PULLUP);
btn_state = digitalRead(btn);
}
void loop() {
btn_currState = btn_state;
btn_state = digitalRead(btn);
if(btn_currState == HIGH) {
Serial.println("led1 active");
led_state = !led_state;
digitalWrite(led1, led_state);
digitalWrite(led2, LOW);
} else {
Serial.println("led2 active");
led_state = !led_state;
digitalWrite(led1, LOW);
digitalWrite(led2, led_state);
}
delay(500);
}