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.
Thanks for any kind of help.
Žan
BLYNK_WRITE(V0)
{
/*---------------------------------BRANJE VIRTUALNEGA STIKALA NA BLYNK---------------------------------*/
int VirtualB = param.asInt();
if(VirtualB != stanje_1)
{
if(VirtualB > stanje_1)
{
koraki_1 = VirtualB - stanje_1;
gor_state_1 = digitalRead(gor_1);
if(gor_state_1 == 0)
{
currentMillis_1 = millis();
}
digitalWrite(gor_1,HIGH);
if(millis() > currentMillis_1 + (perioda * koraki_1))
{
digitalWrite(gor_1,LOW);
stanje_1 = VirtualB;
}
}
if(VirtualB < stanje_1)
{
koraki_1 = stanje_1 - VirtualB;
digitalWrite(dol_1,HIGH);
delay(perioda * koraki_1);
digitalWrite(dol_1,LOW);
stanje_1 = VirtualB;
}
}
}