2. Arduino GPIO Programming Basics

Question.3

Jerry wrote the given code. The circuit is connected as given in the schematic. If the button is pressed, what will be printed on the Serial Monitor?

void setup() {
  pinMode(7, INPUT_PULLUP);
  Serial.begin(9600);
}

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

  if (buttonState == HIGH) {
    Serial.println("Button is pressed");
  } else {
    Serial.println("Button is not pressed");
  }
}

Select Answer