Need help with Blynk Timer

I pretty much have things set up to run code (every second) but I want to be able to (1) manually Start / Stop the timer using a Segmented switch or (2) stop the timer when a predefined time interval has been reached.
Right now the timer works but, of course, starts when I start the sketch and never ends.
All I seem to be able to find is using a “time of day” as the start-stop times.

It’s difficult to give solid advice without having more information, but I would be inclined to keep the timer running continuously, and use your Segmented switch to set a global variable which is then checked to see if the timed function should be executed or not.
Another approach is to use the timer to call a function which checks the value of the global variable set by the Segmented switch and then calls the appropriate function.

Another approach is to disable or delete the timer by referencing it by it’s timer ID, but this makes the process more difficult and you’d need to create a sacrificial timer that occupied ID slot 0, to overcome a bug in Simple timer. That is discussed at length in various topics on this forum.
If you search the internet for SimpleTimer documentation then you’ll see how to enable/disable/delete timers. BlynkTimer is based on SimpleTimer, so the commands are the same.

If you want to use a timer that stops a process after a defined period of time then use a BlynkTimer in timeout mode, probably in a Lambda function. Once again, this is well documented in this forum.

Pete.

Pete,
Thanks a bunch! I can’t say I understood everything you posted but the operative phrase was…“I would be inclined to keep the timer running continuously”. Bingo!
It just never occurred to me it would be an option or that it would be so simple to incorporate into my code. Everything is working now just like I wanted.

1 Like