Blink LED Async
- Async - no delay
Call the routine blink() often in main loop, it will check i 1 second has passed and change led on pin ledPin
void blink() { static boolean blinkLed; static unsigned long Blinktime; const int ledPin = 13; const int delayMsec = 1000; pinMode(ledPin, OUTPUT); if ( millis() > Blinktime ) { if (blinkLed) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW); } blinkLed = !blinkLed; Blinktime = millis() + delayMsec; Serial.println(); Serial.print("Blink.");Serial.print(blinkLed); Serial.println(); }; }
...