int pbIn = 0; // Interrupt 0 is on DIGITAL PIN 2! int ledOut = 13; // The output LED pin volatile int state = LOW; // The input state toggle void setup() { // Set up the digital pin 2 to an Interrupt and Pin 13 to an Output pinMode(ledOut, OUTPUT); //Attach the interrupt to the input pin and monitor for ANY Change attachInterrupt(pbIn, stateChange, RISING); } void loop() { //Simulate a long running process or complex task for (int i = 0; i < 100; i++) { // do nothing but waste some time delay(10); } } void stateChange() { //state = !state; //digitalWrite(ledOut, state); for (int i = 0; i < 60; i++) { delayMicroseconds(16383); } digitalWrite(ledOut, HIGH); // turn the LED on (HIGH is the voltage level) delay(20000); // wait for a second digitalWrite(ledOut, LOW); // turn the LED off by making the voltage LOW }