Hey, my two variables wateringNow (switch widget) and ledWatering (led widget) wont change their status back (l. 63-65), only if I do it by my own on the dashboard...
wateringNow = false;
ledWatering = false;
/*
Sketch generated by the Arduino IoT Cloud Thing "WateringStrawberries"
https://create.arduino.cc/cloud/things/xxx
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
int wateringTime;
bool ledWatering;
bool wateringNow;
Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
which are called when their values are changed from the Dashboard.
These functions are generated with the Thing and added at the end of this sketch.
*/
#include "thingProperties.h"
unsigned long timer = 0;
void setup() {
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
//pin D1 as output
pinMode(16, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
ledWatering = false;
wateringNow = false;
}
void loop() {
ArduinoCloud.update();
if (wateringNow) {
// watering button
// activate pump, led, keep wateringNow true for led on dashboard
ledWatering = true;
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(16, LOW);
// dont use delay(), or the feedback var wont be updated through the main loop
timer = millis();
while(millis()<timer+wateringTime*1000){
}
// deactivate anything again
digitalWrite(16, HIGH);
digitalWrite(LED_BUILTIN, HIGH);
wateringNow = false;
ledWatering = false;
}
}
void onWateringTimeChange() {
// Add your code here to act upon WateringTime change
}
void onWateringNowChange() {
}
Could someone please help me?
Thanks!