Is there anyway to have a cancel command?

So currently I’ve been having an issue with integrating a cancel command into my watering timer. For simplicity my code is just a while loop with the condition that its unlocked and the cancel switch is not activated, and inside the loop i have my pump turn on and then a simple millis timer and pump turn off.

Everything works else works as expected, but when I hit the cancel switch it wont break the loop and stop the pump, I have figured out that the value to cancel the pump is delivering to blynk after the function has ended because I cant water while the cancel switch is on (i intend to make it a button once its working).

Didnt really think code was necessary for this one but lmk if that would be easier.

Using while loops with Blynk is a very bad idea.
They block code execution, and can cause disconnections and un-responsiveness to Blynk commands - as you’ve discovered.

If you want to use a loop then BlynkTimer is a much more sensible approach.
I can’t really explain more about how you’d implement this as you haven’t included your sketch or any information about the widgets you are using, and which pins/datastreams those widgets are attached to.


1 Like