int button1Pin = 2;
int button2Pin = 3;
int ledPin = 13;
int button1State = 0;
int button2State = 0;
void setup() {
pinMode(button1Pin, INPUT);
pinMode(button2Pin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
button1State = digitalRead(button1Pin);
button2State = digitalRead(button2Pin);
// If button 1 is pressed, turn on the LED
if (button1State == HIGH) {
digitalWrite(ledPin, HIGH);
} else if (button2State == HIGH) {
// If button 2 is pressed, turn off the LED
digitalWrite(ledPin, LOW);
delay(100);
}
if (button2State == LOW) {
digitalWrite(ledPin, HIGH);
} else if (button1State == HIGH) {
// If button 2 is pressed, turn off the LED
digitalWrite(ledPin, HIGH);
delay(100);
}
if (button1State == LOW) {
digitalWrite(ledPin, LOW);
} else if (button2State == LOW) {
// If button 2 ispressed, turn off the LED
digitalWrite(ledPin, HIGH);
}
if (button2State == HIGH) {
digitalWrite(ledPin, LOW);
} else if (button1State == LOW) {
// If button 2 is pressed, turn off the LED
digitalWrite(ledPin, LOW);
delay(100);
}
}