I have several led strips that I currently control with Blynk.
Now I’m trying to go further, and make them do the strobe effect with a virtual pin.
I have used the Simple Timer library to switch the led strips state with a push button, and I was thinking if it could be possible to use this same library for doing this.
I recently did something similar with pulsing a relay. Try this concept: Producing pulses Just adjust the times and flash the LEDS instead of the relay.
// Non-blocking pulse routine every 500ms for three times, leaving the relay activated for 100ms each time.
BLYNK_WRITE(V1) // Virtual button on V1 to activate relay pulses
{
int RLY = param.asInt();
if (RLY == 1)
{
timerV1.setTimer(500, RelayON, 3); // Pulse Relay ON routine three times in 500ms
}
}
void RelayON()
{
digitalWrite(2, HIGH); // Activate relay
timerV1.setTimer(100, RelayOFF, 1); // RunRelay OFF routine once in 100ms
}
void RelayOFF()
{
digitalWrite(2, LOW); // deactivate relay
}
// Non-blocking pulse routine every 500ms for three times, leaving the relay activated for 100ms each time.
BLYNK_WRITE(V1) // Virtual button on V1 to activate relay pulses
{
int RLY = param.asInt();
if (RLY == 1)
{
timerV1.setTimer(500, RelayON, 3); // Pulse Relay ON routine three times in 500ms
}
}
void RelayON()
{
digitalWrite(2, HIGH); // Activate relay
timerV1.setTimer(100, RelayOFF, 1); // RunRelay OFF routine once in 100ms
}
void RelayOFF()
{
digitalWrite(2, LOW); // deactivate relay
}
let update this a bit…
// Non-blocking pulse routine every 500ms for three times, leaving the relay activated for 100ms each time.
BLYNK_WRITE(V1) { // Virtual button on V1 to activate relay pulses
if (param.asInt()) {
timerV1.setTimer(500, [](){
digitalWrite(2, HIGH); // Activate relay
timerV1.setTimer(100, [](){
digitalWrite(2, LOW); // deactivate relay
}, 1); // RunRelay OFF routine once in 100ms
}, 3); // Pulse Relay ON routine three times in 500ms
}
}