you can check my Noiasca Took Kit for LEDs .
The rhythm led can be used for this double(tripple) blinking.
See the example led/0112_rhythm_led for several effects:
/*
Rhythm LED
a LED blinking/strobe in a 4 sequence blinking according to ECE 2
change the effect with a button press
The times according to ECE2 are:
ON OFF ON OFF
150, 60, 20, 270
by noiasca
2022-01-17
*/
#include <Noiasca_led.h> // download library from http://werner.rothschopf.net/microcontroller/202202_tools_led_en.htm
#include <Noiasca_button.h> // some tools to read buttons
RhythmPin rhythmLed {13}; // declare LED and assign pin
Button button[] {A0, A1, A2, A3}; // button connects pin with GND, "active LOW"
byte currentEffect = 0; // this sketch allows to switch through different effects
void setup() {
Serial.begin(115200);
rhythmLed.begin(); // you have to call the .begin() method for the LED
rhythmLed.on(); // you can switch the effect on
for (auto &obj : button)
{
obj.begin(); // you have to call the .begin() method for each button
}
}
void loop() {
// read the buttons
if (button[0].wasPressed())
{
Serial.println(F("button 0 was pressed, switch ON LED"));
rhythmLed.on(); // switch on LED
}
if (button[1].wasPressed()) {
Serial.println(F("button 1 was pressed, switch OFF LED"));
rhythmLed.off(); // switch off LED
}
if (button[2].wasPressed()) {
Serial.println(F("button 2 was pressed, toogle LED (change from ON to OFF or vice versa)"));
rhythmLed.toggle(); // if button was pressed, toggle (change state) of blinkLed
}
if (button[3].wasPressed()) {
currentEffect++;
if (currentEffect >= 4) currentEffect = 0;
Serial.print(F("button 3 was pressed, currentEffect="));
Serial.print(currentEffect);
// you can modify the interval in sequence of ON, OFF, ON, OFF
// the function takes the parameters in pairs (2, 4, 6 or 8 values)
switch (currentEffect)
{
case 1 :
Serial.println(F(". ECE 1"));
rhythmLed.setInterval(180, 320); // ECE 1 ON = 180ms, OFF = 320ms
break;
case 2 :
Serial.println(F(". HELLA 3"));
rhythmLed.setInterval(25, 25, 25, 25, 25, 375); // HELLA 3
break;
case 3 :
Serial.println(F(". HELLA 4"));
rhythmLed.setInterval(40, 40, 40, 40, 40, 40, 40, 220); // HELLA 4
break;
default :
Serial.println(F(". ECE 2"));
rhythmLed.setInterval(150, 60, 20, 270); // ECE 2 --> default
break;
}
}
rhythmLed.update(); // you have to call update() for each LED
// put other non blocking code here, to run repeatedly
}
the minimal example is something like:
#include <Noiasca_led.h> // download library from http://werner.rothschopf.net/microcontroller/202202_tools_led_en.htm
RhythmPin rhythmLed {13}; // declare LED and assign pin
void setup() {
rhythmLed.begin(); // you have to call the .begin() method for the LED
// ON OFF ON OFF
rhythmLed.setInterval(100, 150, 100, 1500);
rhythmLed.on(); // you can switch the effect on
}
void loop() {
rhythmLed.update(); // you have to call update() for the LED
}
it should be very easy to introduce more LEDs.