Simple software timer for the Arduino
https://www.arduino.cc/en/Guide/Libraries
void blinker()
{
if( digitalRead(PIN) == HIGH )
{
digitalWrite(PIN, LOW);
}
else
{
digitalWrite(PIN, HIGH);
}
}
void setup()
{
// creates a Timer that will execute once a second
Timer.repeat(blinker, 1000);
}
void loop()
{
// checks the timer and runs the handlers of expired timers.
Timer.run();
}