// This example shows how to work with external interrupts. // Wiring supports external interrupts 0-7, which are // triggered by digital i/o pins 0-3 and 36-39. Arduino // supports external interrupts on pins 2 and 3. int n = 0; // number of interrupts counted void setup() { Serial.begin(9600); // start serial communication pinMode(39, INPUT); // make pin 39 an input pin // attach routine myRoutine() to ext interrupt 7, and // generate it when the associated pin (39) falls from // HIGH to LOW. Alternatives are LOW, CHANGE, RISING. attachInterrupt(7, myRoutine, FALLING); } void loop() { Serial.println(n); // print current value of n delay(200); } void myRoutine() { n++; // count this interrupt }