How to change simple timer interval dynamically?


i would like to change simple timer interval dynamically from blynk app.
in setup i have this:

autoShiftTimer = timer.setInterval(response, autoShift);

to change response time, i use this:

  if (response != param.asInt() * 100) {
    response = param.asInt() * 100;
    EEPROM.write(17, param.asInt());

    autoShiftTimer = timer.setInterval(response, autoShift);

is this correct method?

No, you can’t do that as RESPONSE has to be a fixed virtual pin that you have assigned to the slider.

no, RESPONSE is != response

RESPONSE is a virtual pin define
and response is the variable to store the millis

I see, it would have been clearer for you to include the define.

What range do you have on the slider?

AFAIK you don’t have to enable a timer after you define it, it will automatically start.
What I do when changing them dynamically is delete the running timer, change the interval and create the timer again.

1 Like

the slider range in the app is 1-20, but this value is multiplied by 100 in the hardware, so the minimum interval is 1 x 100 = 100 millis.

i use the 1 - 10 numbering on the app side, to have cleaner values on the slider.
just tested the method you reccomend, and it works.
thank you!

Hi guys any solution that works?

or could one simply restart the timer which than will start with the new timer interval Count_Down that has been read from eg a slider

timer.setInterval(Count_Down, Thingspeak)


read the post before yours.

SimpleTimer has methods to destroy timers and you can always add another one after that. I’m not sure the restart will work, but have you tried? It’s not like you can break anything with that :wink:

1 Like

I did it and works fine:

{ //slide timelapse

int pinValue = param.asInt();

timerid = timer.setInterval(pinValue * 1000, myCAMSaveToSDFile);