|This page is intended as a reference for core developers only, and the content is only changed after a consensus has been reached through discussion of any such changes. Please use the Discussion page to talk about any changes or issues you have with the current implementation.|
|Classification||Hardware interrupt control methods.|
|Version introduced||1.0 (0100)|
void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), uint8_t mode)
The attachInterrupt() method sets the function that executes whenver an external interrupt is generated. It also sets the mode in which external interrupts can be triggered depending on the state of the interruption pin, LOW when a pin is low, CHANGE when the pin changes state, RISING when the pin goes from low to high or FALLING when the pin goes from high to low.
Black Box Input
The number of the external interruption is provided. EXTERNAL_INTERRUPT_0, EXTERNAL_INTERRUPT_1… etc.
The name of the function to be called whenever the interrupt event happens is provided.
Black Box Output
Nothing is returned.
None. Single function only.
It is possible to generate and attend external interrupts on the Wiring hardware. On Wiring v1 boards the external interrupts capable pins are: 0, 1, 2, 3, 36, 37, 38 and 39. On Wiring S board the external interrupts capable pins are: 2, 3 and 18. In addition to being regular digital pins, note that some of these pins are also used for libraries like Wire or Serial/Serial1.
The Interruption mode can also be set at a later time by using the interruptMode() method.
WARNING: you should avoid doing long procedures in interrupt routines.