/* Repeating Timer Code Alternative to ElapsedMillis (c)2015 Forward Computing and Control Pty. Ltd. This code may be freely used for both private and commerical use. Provide this copyright is maintained. */ int led = 13; unsigned long timer; // the timer unsigned long INTERVAL = 1000; // the repeat interval void setup() { pinMode(led, OUTPUT); // initialize LED output timer = millis(); // start timer } void loop() { if ((millis()-timer) > INTERVAL) { // timed out timer += INTERVAL;// reset timer by moving it along to the next interval // toggle led if (digitalRead(led)) { digitalWrite(led, LOW); // turn the LED off by making the voltage LOW } else { digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) } } }