Good stuff to follow.
unsigned long eventInterval; unsigned long previousTime; void setup() { eventInterval=5000; // 5 seconds previousTime=millis(); } void loop() { unsigned long currentTime = millis(); /* This is the event */ if (currentTime - previousTime >= eventInterval) { /* Event code */ Serial.println("Timeout"); /* Update the timing for the next time around */ previousTime = currentTime; } }