| Index

| Reference for Wiring 1.0 (ALPHA) 0017+. If you have a previous version, use the reference included with your software. If you see any errors or have any comments, let us know.

Name |  | ### attachInterrupt()
Examples |  |
    void setup() {
      attachInterrupt(0, myFunction, LOW); // set myFunction to be called everytime
                                      // interrupt 0 is generated (everytime the pin gets LOW)
      Serial.begin(9600);             // Starts serial to print data
    }

    void loop() {

    }

    void myFunction() {
      Serial.print("hello ");
    }
Description |  | It is possible to generate and attend external interrupts on the Wiring I/O board. There are 8 external interrupts, from 0 to 7 so there are 8 pins on the Wiring I/O board capable of external interrupts, 0, 1, 2, 3, 36, 37, 38, and 39 respectively. In addition to being regular digital pins, note that pins 0 and 1 are also used for the Wire library (TWI) and pins 2 and 3 are also the Serial1 serial port pins. 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 interreuption pin pin, LOW when a pin is low, CHANGE when the pin changes, RISING when the pin goes from low to high or FALLING when the pin goes from high to low. The Interruption mode can also be set at a later time by using the interruptMode() method.
Syntax |  |
    attachInterrupt(interrupt, function, mode)
Parameters |  |
interrupt |  | The number of the external interrupt, from 0 to 7
function |  | The name of the function to be called whenever the interrupt event happens
mode |  | LOW, CHANGE, RISING or FALLING: the mode the external interrupt is triggered
Returns |  | None
Usage |  | Application
Related |  | detachInterrupt() interruptMode() LOW CHANGE FALLING RISING