Question.3
Bob is a space cat who found the following circuit &code, He has to turn ON LED, which buttons do he need to press?
int button1 = 17;
int button2 = 16;
int button3 = 4;
int ledPin = 2;
void setup() {
pinMode(button1, INPUT_PULLDOWN);
pinMode(button2, INPUT_PULLUP);
pinMode(button3, INPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
}
void loop() {
int state1 = digitalRead(button1);
int state2 = digitalRead(button2);
int state3 = digitalRead(button3);
if (state1 == HIGH || state2 == HIGH || state3 == HIGH) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
}