#define sw1 13
#define LED1 22
#define sw2 12
#define LED2 23
boolean sw1_state, last_sw1_state = LOW;
boolean sw2_state, last_sw2_state = LOW;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(sw1, INPUT_PULLUP);
pinMode(LED1, OUTPUT);
pinMode(sw2, INPUT_PULLUP);
pinMode(LED2, OUTPUT);
last_sw1_state = digitalRead(sw1);
last_sw2_state = digitalRead(sw2);
}
void loop() {
sw1_state = digitalRead(sw1);
if(last_sw1_state != sw1_state){
delay(50);
if (sw1_state == LOW)
digitalWrite(LED1, HIGH);
else
digitalWrite(LED1, LOW);
last_sw1_state = sw1_state;
}
sw2_state = digitalRead(sw2);
if(last_sw2_state != sw2_state){
delay(50);
if (sw2_state == LOW)
digitalWrite(LED2, HIGH);
else
digitalWrite(LED2, LOW);
last_sw2_state = sw2_state;
}
}