Complete the code to attach an interrupt to pin 2 that calls the function handleInterrupt.
attachInterrupt(digitalPinToInterrupt([1]), handleInterrupt, RISING);Pin 2 is the correct pin to attach the interrupt on many Arduino boards.
Complete the code to declare the interrupt service routine function named handleInterrupt.
void [1]() {
// code to run when interrupt occurs
}The function name must match the one used in attachInterrupt.
Fix the error in the code to correctly enable interrupts.
noInterrupts();
// critical code here
[1]();The function interrupts() re-enables interrupts after noInterrupts().
Fill both blanks to create a dictionary that maps pin numbers to their interrupt numbers.
const int interruptMap[] = { [1]: 0, [2]: 1 };Pin 2 maps to interrupt 0 and pin 3 maps to interrupt 1 on many Arduino boards.
Fill all three blanks to complete the code that sets up an interrupt and handles it.
volatile bool flag = false; void [1]() { flag = true; } void setup() { attachInterrupt(digitalPinToInterrupt([2]), [3], FALLING); } void loop() { if (flag) { flag = false; // handle event } }
The interrupt service routine is named handleInterrupt, attached to pin 2, and the function name is handleInterrupt.