This example is for Wiring version 0027+. If you have a previous version, use the examples included with your software. If you see any errors or have comments, please let us know.
External interrupts by BARRAGAN
Demonstrates how to attend an externa interrupt generated on the digital pin 0. 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.
void setup() {
// set myFunction to be called everytime
// interrupt 0 is generated (everytime the pin gets HIGH)
attachInterrupt(0, myFunction, HIGH);
Serial.begin(9600); // Starts serial to print data
}
void loop() {
}
void myFunction() {
Serial.print("Interrupt generated");
}