Arduino Iot led widget wont turn on

Hey, I have created a Iot dashboard to water my plants with a esp8266.

void watering(int timeWater) {
  wateringFeedback = true;
  digitalWrite(LED_BUILTIN, HIGH);
  digitalWrite(16, HIGH);
  delay(timeWater * 1000);
  digitalWrite(16, LOW);
  digitalWrite(LED_BUILTIN, LOW);
  wateringFeedback = false;
}

the wateringFeedback var is connected to widget:

As soon as I call the watering function, the pin is turned on and the led on the board also.
But the led widget stays the same...
The var wateringFeedback is changing its value on change.

Does someone maybe know what I am doing wrong?
Thanks!

Hi @kaffemitmilf,
i suppose you are calling the watering function somewhere in the loop. Using the delay function you are blocking the update loop and so there is no chance the underlying library can update the wateringFeedback variable. You have to use a different pattern with a non blocking delay to keep the update loop running.

Mattia

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.