// Blink Without Delay example.
//
// So, everyone wants newbies to write blink without delay. This is good,
// because delay() is bad. Well, here's a simple way to do it..
// Have fun!
// jim lee,
// https://github.com/leftCoast/LC_baseTools/tree/master/examples/blinkWithoutDelay
//
// modified by Edoctoor Feb 1, 2022
#include "timeObj.h"
timeObj aTimer; // Allocate a global timer.
int LEDPin = 13; // The onboard LED we want to blink
bool LEDOn = false; // We will save the state of the LED here.
void setup() {
pinMode(LEDPin, OUTPUT); // Initialize the digital pin as an output.
aTimer.setTime(500); // Set the timer for 500 ms. (1/2 second)
aTimer.start(); // Fire up the timer.
}
void loop() {
if (aTimer.ding()) { // If the timer has expired..
if (LEDOn) { // If the LED is on..
digitalWrite(LEDPin, LOW); // Turn LED off.
LEDOn = false; // Make a NOTE of it.
} else { // Else, the LED was off.
digitalWrite(LEDPin, HIGH); // Turn the LED on.
LEDOn = true; // Make a NOTE of it.
}
aTimer.start(); // Restart the timer.
}
}