Interrupt

This library is for using an interrupt operation from specified pins.

attachInterrupt

Description

Specifies a function to call when an external interrupt occurs. Replaces any previous function that was attached to the interrupt. The board has two external interrupts: number0 (on digital pin2), 1 (on digital pin3). The function to call has no parameter and no return.

Syntax

attachInterrupt(unsigned char interrupt, void(*)(void) func, int mode)

Parameters

interrupt: Specify interrupt number 0 or 1(int)
function: Specify the function to call when an interrupt occurs; this function must take no parameters and return nothing. This function is sometimes referred to as an interrupt service routine.
mode: CHANGE (whenever the pin changes value), FALLING (when the pin goes from high to low), RISING (when the pin goes from low to high)

Returns

None

Remarks

LOW cannot be specified to mode. In the case of specifying LOW, CHANGE is specified.
The functions used by the system are not executed during interrupt operating so delay(), millis(), Serial() do not work well.

detachInterrupt

Description

Turns off the given interrupt.

Syntax

detachInterrupt(unsigned char interrupt)

Parameters

interrupt: The number of the interrupt to disable.(0 or 1)

Returns

None

interrupts

Description

Re-enables interrupts (after they've been disabled by noInterrupts()).

Syntax

interrupts()

Parameters

None

Returns

None

noInterrupts

Description

Disables interrupts (you can re-enable them with interrupts()). Interrupts allow certain important tasks to happen in the background and are enabled by default. Some functions will not work while interrupts are disabled, and incoming communication may be ignored. Interrupts can slightly disrupt the timing of code, however, and may be disabled for particularly critical sections of code.

Syntax

noInterrupts()

Parameters

None

Returns

None


Example

Under description.


        #include <Arduino.h>