//BasicSingleShotDelay.ino int led = 13; // Pin 13 has an LED connected on most Arduino boards. unsigned long DELAY_TIME = 10000; // 10 sec unsigned long delayStart = 0; // the time the delay started bool delayRunning = false; // true if still waiting for delay to finish void setup() { pinMode(led, OUTPUT); // initialize the digital pin as an output. digitalWrite(led, HIGH); // turn led on // start delay delayStart = millis(); delayRunning = true; } void checkTurnOffLed() { // check if delay has timed out if (delayRunning && ((millis() - delayStart) >= DELAY_TIME)) { delayRunning = false; // finished delay -- single shot, once only digitalWrite(led, LOW); // turn led off } } void loop() { checkTurnOffLed(); // call the led task may just return }