Yes, clarity of the question and situation is generally helpful ![]()
This will wait for your Button Widget to be pressed. Once pressed, it will run the non-blocking pulse routine every 500ms for three times, leaving the relay activated for 100ms each time.
If you want it to activate the routine immediately at button push, then you will have to fiddle around with the placement of the digital writes and timers.
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
}