Question.7
Gary has built the following circuit. Which of the following cases will turn ON the LED?
const int button1Pin = 4;
const int button2Pin = 5;
const int ledPin = 2;
void setup() {
pinMode(button1Pin, INPUT_PULLUP);
pinMode(button2Pin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
bool button1State = digitalRead(button1Pin);
bool button2State = digitalRead(button2Pin);
if (button1State || button2State) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
}