Script keeps halting (on MEGA via USB link)

@vshymanskyy because the name BlynkTimer suggests it’s a Blynk function and they wrongly think the code will not work when users don’t have internet access.

@Costas @vshymanskyy Perhaps just a bit more clarification in the documentation… something like this?

BlynkTimer is the same as the widely used SimpleTimer library, in that it works more elegantly than manually manipulating millis() and it is NOT dependent on a connection to a Blynk Server, and also fixes some minor issues with the original library.

A typical Interval Timer layout includes a definition, timer setup (pointing to a function) and a timer call in the void loop():

BlynkTimer Mytimer; // Sets up a timer object named Mytimer (could be any name)

Mytimer.setInterval(1000L, MyFunction);  // Goes in Setup() and will call the void MyFunction() every 1000 milis (one second - adjust to your needs).  Blynk Timer allows up to 16 of these same object named timers pointing to differing functions

void MyFunction() 
{
// Mytimer runs stuff here every 1000 millis (one second)
}

void loop()
{
Blynk.run();
Mytimer.run();  // Goes in the void loop() so the BlynkTimer library can run.
}
3 Likes