I’m using the standalone example. On the App I’m using Timer from an specific time to 5 secs later. It only turns the port high and doesn’t change back to low.
I would use virtual pins, and instead of tying to manipulate the relay directly I would use code.
For example:
BLYNK_WRITE(V5)
{
int value = param.asInt(); // Get value as integer
if (value == 1)
{
digitalWrite(pin, LOW);
timer.setTimeout(5000L, []() { // Run every 5 second
digitalWrite(pin, HIGH);
Blynk.virtualWrite(V5, LOW);
}); // END Timer Function
}
}
Hey, that looks promising. I’m unfamiliar with virtual pins, so if I turn V5 on with a Timer it will shut off after 5000?.. Interesting, will try that.
Hi @Toro_Blanco ,
What does this line do when V5 is associated to a push button to turn on/off a relay? Is it there to satisfy the Lambda expression? I noticed that the code works without it. Thx
In this particular case where it is being triggered by the timer it may not be absolutley necessary, same for a button widget that has its mode set as push.
I put it in there to make V5 return to the Off/LOW state. If the button widget is set as a switch, it will return the button to the Off/LOW state.
For example, say you had a button widget linked to V5, mode set to switch. When you pressed the button it would go On/HIGH and stay that way for 5 seconds, indicating that whatever task it is doing is on. It will then return to its Off/LOW state after the 5 seconds have passed indicating that the process is over.
It is probably more for the visual aspect than anything, but I use it none the less.
Although, I can also picture a case where if using this line of code below (which I do often use) without the Blynk.virtualWrite(V5, LOW);, you may get a false trigger on startup as V5 will always be On/HIGH.
I’m looking at this on my iPad, so it’s difficult to follow the code, but I think you need to sort out your curly brackets.
Your void setup needs a closing curly bracket before the BLYNK_WRITE(V5) function begins.
And this looks all wrong…