const int button1Pin = 2; // Pin for Button 1
const int button2Pin = 3; // Pin for Button 2
const int ledPin = 13; // Pin for the LED
void setup() {
pinMode(button1Pin, INPUT_PULLUP); // Set Button 1 as input with internal pull-up resistor
pinMode(button2Pin, INPUT_PULLUP); // Set Button 2 as input with internal pull-up resistor
pinMode(ledPin, OUTPUT); // Set LED pin as output
digitalWrite(ledPin, LOW); // Ensure LED is off at the start
}
void loop() {
// Read the state of both buttons
bool button1State = digitalRead(button1Pin) == LOW; // Button pressed is LOW
bool button2State = digitalRead(button2Pin) == LOW; // Button pressed is LOW
// If either button is pressed, toggle the LED state
if (button1State || button2State) {
digitalWrite(ledPin, !digitalRead(ledPin)); // Toggle the LED
delay(200);
}
}