#define BUTTON_PIN1 5 // Push button 1 connected to pin 5
#define BUTTON_PIN2 6 // Push button 2 connected to pin 6
#define LED_1 10 // LED connected to pin 10
#define LED_2 11 // LED connected to pin 11
int button_state1 = 0; // Variable to store button 1 value
int button_state2 = 0; // Variable to store button 2 value
void setup() {
pinMode(BUTTON_PIN1, INPUT_PULLUP); // Set pin to input with pullup
pinMode(BUTTON_PIN2, INPUT_PULLUP); // Set pin to input with pullup
pinMode(LED_1, OUTPUT); // Set pin to output
pinMode(LED_2, OUTPUT); // Set pin to output
}
void loop() {
button_state1 = digitalRead(BUTTON_PIN1);
button_state2 = digitalRead(BUTTON_PIN2);
if(button_state1 == LOW){
digitalWrite(LED_1, HIGH); // turn LED 1 on
} else if (button_state2 == LOW){
digitalWrite(LED_2, HIGH); // turn LED 2 on
} else {
digitalWrite(LED_1, LOW); // turn LED 1 off
digitalWrite(LED_2, LOW); // turn LED 2 off
}
}