/** BasicFlashingLed.ino by Matthew Ford, 2020/01/27 (c)2019 Forward Computing and Control Pty. Ltd. NSW, Australia www.forward.com.au */ // this sketch runs on Uno and most other Arduino boards // it uses millisDelay from https://www.forward.com.au/pfod/ArduinoProgramming/TimingDelaysInArduino.html // download and install the millisDelay library https://www.forward.com.au/pfod/ArduinoProgramming/millisDelay.zip #include "millisDelay.h" int ledPin = 13; // built in led on most boards bool ledOn = false; // is the led on or off millisDelay ledDelay; unsigned long LED_DELAY_MS = 1000; // on/delay in mS == 1sec void setup() { pinMode(ledPin, OUTPUT); // set output digitalWrite(ledPin, LOW); // turn led off ledDelay.start(LED_DELAY_MS); // start led flash delay ledOn = false; // start off } void loop() { if (ledDelay.justFinished()) { ledDelay.restart(); // restart it ledOn = !ledOn; // toggle ledOn if (ledOn) { digitalWrite(ledPin, HIGH); // turn on } else { digitalWrite(ledPin, LOW); // turn off } } }