Question.5
After uploading the following code to an Arduino UNO, what will happen when the push-button connected to pin 2 is pressed multiple times?
Note: Consider no noise is created from button press.
Code
#define BUTTON_PIN 2
#define LED 12
void INT0_ISR() {
digitalWrite(LED, !digitalRead(LED));
cli(); // Disable global interrupts
}
void setup() {
pinMode(BUTTON_PIN, INPUT_PULLUP); // Enable internal pull-up resistor for INT0 pin
pinMode(LED, OUTPUT);
// Attach INT0 interrupt (pin 2) with falling edge trigger
attachInterrupt(digitalPinToInterrupt(BUTTON_PIN), INT0_ISR, FALLING);
sei(); // Enable global interrupts
}
void loop() {
}