Hello everyone, I have a problem that it wouldn’t go into if loop after millis() are greater than in code: if(millis() > currentMillis_1 + (perioda * koraki_1)). So what happens is gor_1 stays HIGH all the time.
So my question is, does the program process my code in BLYNK_WRITE(V0); only when there is change with int VirtualB or does it checks it all the time and if so how can I fix it?
I know there exists some kind of Blynk timer, but if there is any way of fixing this I would prefere using this. Also my IF statement may be wrong.
I honestly do not understand your question as it refers to millis()… but…
… a BLYNK_WRITE(Vpin) function is only processed when the widget (assigned to the Vpin) in the App experiences a state/data change.
The only way to run a Blynk function via code is to cause a change in the state/data via code - with a Blynk.virtualWrite(vPin, value) followed by a Blynk.syncVirtual(vPin) which then causes the function to run with new value.
Or, if just wanting the function to use the current vPin state, then the Blynk.syncVirtual(vPin) by itself will cause the function to run with last known state/data.
You can’t use BLYNK_WRITE as a loop. It’s a special function, like a callback, that triggers automatically when the Blynk server detects a chance in the widget attached to the relevant virtual pin, or when a Blynk.syncVirtual call is made.
If you want a continuous loop then create a function that is called with a timer. Otherwise use a timeout timer.
Your void loop should always be as simple as possible, preferably with just Blynk.run and timer.run
No, you don’t ‘watch’ the timer, you tell the timer which function to call and how often, then it does it automatically.
Maybe if you have a more complete description of what it is that you are trying to achieve (without turning that into a coding solution) then we’d be able to guide you better.
Okay, in that case you should use a timeout timer for each slider. When the BLYNK_WRITE callback for motor 1 is triggered then it starts the timer and starts the motor moving. When the timer ends it will stop the motor.
Same for the other two callbacks, each with separate timeout timers.
Okay that is what I thought as well. Thanks for your help Pete. Is there any way of tagging you if I will run into other problems with this same project, so I wont have to open another question?