64. Interrupt Operation

Question.3

Based on the following setup and code, what will be printed on the serial monitor when button 1 is pressed & released, and then button 2 is pressed & released?

Note: Consider no noise is created from button press.

Code

#include <avr/interrupt.h>
volatile int interruptCount = 0;

void setup() {
  pinMode(2, INPUT_PULLUP);  // Button 1
  pinMode(3, INPUT_PULLUP);  // Button 2

  attachInterrupt(digitalPinToInterrupt(2), handleInterrupt, FALLING);
  attachInterrupt(digitalPinToInterrupt(3), handleInterrupt, FALLING);

  Serial.begin(115200);
}

void loop() {
  
}

void handleInterrupt() {
  interruptCount++;
  Serial.print("Interrupt Count: ");
  Serial.println(interruptCount);
}

Select Answer