Hi, I’m trying to read a virtual pin, and if active, activate a physical pin for a certain number of seconds, and then always turn it off for a certain number of seconds.
I tried the following code and it works, only when the virtual pin becomes 0, the loop doesn’t stop.
How can I solve?
Thank you.
BLYNK_WRITE(V4) // Virtual button on Vx to activate action
{
int BTN = param.asInt();
if (BTN == 1) {
digitalWrite(ledpin, HIGH); // Run ActionON function
timer.setTimeout(1000L, ActionON);
}
}
void ActionON()
{
digitalWrite(ledpin, HIGH); // Set pin high
timer.setTimeout(2000L, ActionOFF); // Run ActionOFF function in 5 seconds
}
void ActionOFF()
{
digitalWrite(ledpin, LOW); // Set pin Low
timer.setTimeout(1000L, ActionON);
}