I have an ESP8266 attached to my mac.
The intention is very simple: I have a switch on the dashboard. If I put it 'on', the LED_BUILTIN should lit up, else it should go off.
Here is my code:
/*
The following variables are automatically generated and updated when changes are made to the Thing
bool ledBtn;
*/
#include "thingProperties.h"
bool ledStatus = HIGH;
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(1500);
// Defined in thingProperties.h
initProperties();
pinMode(LED_BUILTIN, OUTPUT);
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
}
void loop() {
ArduinoCloud.update();
}
/*
Since LedBtn is READ_WRITE variable, onLedBtnChange() is
executed every time a new value is received from IoT Cloud.
*/
void onLedBtnChange() {
// Add your code here to act upon LedBtn change
if (ledBtn){
ledStatus = HIGH;
}else{
ledStatus = LOW;
}
digitalWrite(LED_BUILTIN,ledStatus);
Serial.println(ledStatus);
}
In my Dashboard I have a simple on/of button which is linked to ledBtn variable.
If I change the button, the serial monitor gives me the correct output (0 1 0 1 0 1, ...)
The LED_BUILTIN unfortionaly does nothing.
I tried a simular sketch in de desktop IDE and there it works (I used a timer instead of the Dashboardswitch.)
I get no errormesages .
Can someone help me with this? What am I not seeing here?