I was making a simple code to turn on and off LED using the IOT cloud. I would send signals from my phone using the iot dashboard and the ESP8266 would receive the signal and send 0 or 1. The signal is being received and the lights turn on, but when i try to turn off the lights, it doesnt work. In the dashboard, i have 4 switches and 4 LED to indicate the on and off of the 4 lights. When i switch it on, it works normally, but if i switch it off, it just turns back on again (in the dashboard). The LEDs on my desk dont turn off at all. I have tried a lot in the settings, nothing works. Cannot figure out the issue.
/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled"
https://create.arduino.cc/cloud/things/7f76fd85-d221-4b46-a1b4-29f6e41ad187
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
CloudLight corner_Lights;
CloudLight edge_Lights;
CloudLight middle_Light;
CloudLight strip_Light;
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"
#include "ESP8266WiFi.h"
#include "WiFiClient.h"
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
pinMode (D0,OUTPUT);
pinMode (D1,OUTPUT);
pinMode (D2,OUTPUT);
pinMode (D3,OUTPUT);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(100);
// 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();
}
void loop() {
ArduinoCloud.update();
}
/*
Since MiddleLight is READ_WRITE variable, onMiddleLightChange() is
executed every time a new value is received from IoT Cloud.
*/
void onMiddleLightChange() {
if(middle_Light=1){
digitalWrite(D0,HIGH);
}
else{
digitalWrite(D0,LOW);
}
}
void onStripLightChange() {
if(strip_Light=1){
digitalWrite(D1,HIGH);
}
else{
digitalWrite(D1,LOW);
}
}
/*
Since CornerLights is READ_WRITE variable, onCornerLightsChange() is
executed every time a new value is received from IoT Cloud.
*/
void onCornerLightsChange() {
if(corner_Lights=1){
digitalWrite(D2,HIGH);
}
else
{
digitalWrite(D2,LOW);
}
}
/*
Since EdgeLights is READ_WRITE variable, onEdgeLightsChange() is
executed every time a new value is received from IoT Cloud.
*/
void onEdgeLightsChange()
{
if(edge_Lights=1) {
digitalWrite(D3,HIGH);
}
else{
digitalWrite(D3,LOW);
}
}