4. Arduino GPIO Usage and Applications

Question.7

Maria has build the following circuit. Which of the following statement is true? 

 

const int buttonPin = 2;
const int bulbPin = 4;

void setup() {
  pinMode(buttonPin, INPUT_PULLUP);
  pinMode(bulbPin, OUTPUT);
  digitalWrite(bulbPin, LOW);
}

void loop() {
  int buttonState = digitalRead(buttonPin);

  if (buttonState == LOW) {
    digitalWrite(bulbPin, HIGH);
  } else {
    digitalWrite(bulbPin, LOW);
  }
}

Select Answer