Arduino Timer Interrupts

Here is a small example how you can create timer interrupts with the arduino. For this example you need the TimerOne library.

#include "TimerOne.h"  
int iPin=13;
int iSeconds=1;

void setup() {
    pinMode(iPin, OUTPUT);
    Timer1.initialize(iSeconds*1000000);
    Timer1.attachInterrupt(fBlink);
}

void fBlink() {
    digitalWrite(iPin, digitalRead(iPin) ^ 1);
}

void loop() {
    // nothing to do here
}