While loop never stops

I have a problem:

int time = slide1*1000;
int start=millis();
while(millis()-start <= time){

Slide1 is a component on my phone app, I want to cycle until while time limit is > than that I catch from the app ( I didn’t post more code because it works) with a slide
With this code, the loop never stops but if I change the variable slide1 with a fixed time ( for example 30000) , it works perfectly .

Any idea?

Don’t use while loops with Blynk.
Use BlynkTimer instead. In this case, probably a Timeout Timer in a Lambda function…


It is not a recursive operation, it is a function that moves a motor until it opens a window, how can I use a timer if this operation is not needed every time?

Did you read the Timeout Timers section of the topic I linked to?
This type of timer can be triggered when required and used as a one-shot timer, which seems to be exactly what you require.


I guess it’s better to use a limit switch instead of timer

In which way?

When it rains I need to close some windows for a duration that is chosen by a slider widget on the app .

int time = slider1*1000

Are you using blynk IOT or legacy ?

it is an old Legacy prototype

Can you post the whole sketch please ?