Arduino Helpers master
Utility library for Arduino
BlinkWithoutDelay-Timer.ino

BlinkWithoutDelay-Timer

This examples shows how use the Timer class to blink an LED every second, in a non-blocking fashion (without using delay).

Boards:
AVR, AVR USB, Nano Every, Nano 33 IoT, Nano 33 BLE, UNO R4, Pi Pico, Due, Teensy 3.x, ESP8266, ESP32

Behavior

Blinks the built-in LED every second.

Written by PieterP, 2019-12-06
https://github.com/tttapa/Arduino-Helpers

Timer<millis> timer = 500; // milliseconds
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
if (timer) {
digitalWrite(LED_BUILTIN, digitalRead(LED_BUILTIN) ? LOW : HIGH);
}
}
constexpr PinStatus_t LOW
constexpr PinStatus_t HIGH
constexpr PinMode_t OUTPUT
Dummy header file for Arduino builder.
A class for easily managing timed events.
void pinMode(pin_t pin, PinMode_t mode)
An ExtIO version of the Arduino function.
PinStatus_t digitalRead(pin_t pin)
An ExtIO version of the Arduino function.
void digitalWrite(pin_t pin, PinStatus_t val)
An ExtIO version of the Arduino function.