#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() {
Serial.begin(9600);
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){
for(int x = 0; x<10; x++){
Serial.print("x = ");
Serial.println(x);
(LED_1, HIGH); // turn the LED on
delay(200);
digitalWrite(LED_1, LOW); // turn the LED off
delay(200);
}
} else if(button_state2 == LOW){
for(int y = 0; y<10; y++){
Serial.print("y = ");
Serial.println(y);
digitalWrite(LED_2, HIGH); // turn the LED on
delay(200);
digitalWrite(LED_2, LOW); // turn the LED off
delay(200);
}
}
}