Blinker: ESP32 library for LED blinking


I could not find a library for easily controlling the blink periods for various LEDs for 1-of-10 ESP32 projects I have been working on, so I wrote one. I am sure there are a million out there. There are now one-million-and-one. To be honest, I did not look very hard.

I had been using TimedBlink (not written for ESP32, and old). Things started messily and got messier.

My implementation in ESP32-blinker uses ESP32 SDK timers API (via Ticker.h` in Arduino-Core-for-ESP32) so is ‘pseudo’ async (I think).

Anyway hopefully useful to someone. Skip over to readme for usage.

Example

#include "Blinker.h"
#include "Ticker.h

#define BLINKER_PIN 10

#define ON_TIME 1.0f
#define OFF_TIME 0.5f

Blinker myBlinker(BLINKER_PIN);

Ticker changer;

void changeUp1(){
    myBlinker.snapshot();
    myBlinker.continuousOn();
}

void changeUp2(){
    myBlinker.resume(); //resume blink pattern snapped in changeup1
}

void setup(){
    myBlinker.blink(ON_TIME,OFF_TIME);
    changer1.once(10,changeUp1);
    changer2.once(20,changeUp2);
}

void loop(){
    //dont need to anything here with millis() and wotnot. 
}

Series Navigation

<< ESPmDNS: An ESP32 secret (to me anyway)