Detach interrupts from a source in Arduino


We have seen that in order to attach interrupts to a source, we use the .attachInterrupt() function, with the required arguments.

For example, for attaching the interrupts to a specific pin, we use

attachInterrupt(digitalPinToInterrupt(pin), ISR, mode);

In the same way, to detach the interrupt from a source, we can call the detachInterrupt() function. This will simply disable that particular interrupt. The recommended syntax for disabling pin interrupts is −

detachInterrupt(digitalPinToInterrupt(pin))

where pin is the pin number on which you wish to disable the interrupt.

Updated on: 31-May-2021

925 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements