#include <TimerOne.h>
#define TIMER_US 100000 // 100mS set timer duration in microseconds
#define TICK_COUNTS 200 // 20S worth of timer ticks
volatile long tick_count = TICK_COUNTS; // Counter for 20S
void setup(){
pinMode(13, OUTPUT);
attachInterrupt(0, blink, FALLING);
// LOW to trigger the interrupt whenever the pin is low,
// CHANGE to trigger the interrupt whenever the pin changes value
// RISING to trigger when the pin goes from low to high,
// FALLING for when the pin goes from high to low.
//Board int.0 int.1
//Uno, Ethernet 2 3
Timer1.initialize(TIMER_US); // Initialise timer 1
Timer1.attachInterrupt( timerIsr ); // attach the ISR routine h
}
// --------------------------
// timerIsr() 100 milli second interrupt ISR()
// Called every time the hardware timer 1 times out.
// --------------------------
void timerIsr(){
if (!(--tick_count)){ // Count to 20S
timer1.stop();
digitalWrite(13, LOW); // Toggle pin 13 LOW
}
}