Complete the code to attach an interrupt to pin 2 that calls the function handleInterrupt.
attachInterrupt(digitalPinToInterrupt(2), [1], RISING);
The function attachInterrupt() requires the name of the function to call when the interrupt occurs. Here, handleInterrupt is the correct function name.
Complete the code to attach an interrupt on pin 3 that triggers on a falling edge and calls the function interruptRoutine.
attachInterrupt(digitalPinToInterrupt(3), interruptRoutine, [1]);
RISING instead of FALLING.LOW which is not a valid mode for attachInterrupt().The third argument of attachInterrupt() specifies the mode. FALLING triggers the interrupt when the signal goes from HIGH to LOW.
Fix the error in the code to correctly attach an interrupt to pin 4 calling the function onInterrupt when the pin changes state.
attachInterrupt([1], onInterrupt, CHANGE);The first argument to attachInterrupt() must be the interrupt number, which is obtained by digitalPinToInterrupt(pin) for the given pin.
Fill both blanks to attach an interrupt on pin 5 that calls the function myISR when the signal goes LOW.
attachInterrupt([1], [2], LOW);
The first blank requires the interrupt number from digitalPinToInterrupt(5). The second blank is the function name myISR to call on interrupt.
Fill all three blanks to create a dictionary mapping pins to their interrupt modes for pins 6, 7, and 8.
interruptModes = {6: [1], 7: [2], 8: [3]The dictionary assigns LOW mode to pin 6, FALLING to pin 7, and CHANGE to pin 8 as interrupt modes.