I everybody,
some time ago I bought an RGB light that can be driven by IR remote control Here the product:
https://www.banggood.com/LUSTREON-20W-30W-50W-DIY-RGB-LED-Light-Chip-Remote-Control-Bulb-Bead-For-Flood-Light-AC220V-p-1329498.html?rmmds=myorder.
My idea is to writing a code (see below) sending the appropriate coding via IR activating the light.
To save space in the layout I decided to use a slider where based on the number selected in the slider I show a specific color.
EX:
from 0 to 100 IR = white
from 101 to 200 IR = blu
and so on…
in terms of hardware I got 3 NODEMCU. Every node have it’s own IR and is placed close to the light.
To club the lights (placed in different location) I used the TAGS functionality where the 3 NODEMCU have the same code (different auth number)
I used 3 device because there are forniture beween each other; no opiton to use just 1 device with different IR.
PROBLEM: after uploading the code and testing it I powered off the NODE MCU and moved on a new power supply. The NODE doesn’t take any connection. If I overwrite code and test again it work perfectly,
My doubt is that my code isn’t so good and “drown” the NodeMCU.
Here the code (maybe was better to use a case intead of IF but I prefer to see you opinion first
/* IR_Remote.ino per http://community.blynk.cc/t/disconnetted-nodemcu/11599 */
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
// IR remote
#include <IRremoteESP8266.h>
#include <IRsend.h>
int IRsentcode;
char auth[] = "AUTH 1/2/3"; //3za luce
char ssid[] = "XXX";
char pass[] = "YYY";
SimpleTimer testingTimer;
IRsend irsend(0); ///an IR led is connected to GPIO 0 --> D3
BLYNK_WRITE(V10) // ON/OFF
{
IRsentcode = param.asInt();
if (IRsentcode > 900) //WHITE
{ irsend.sendNEC(0xF7E01F, 32); // telecomando a 24 bottoni
}
if (IRsentcode <= 100) //OFF
{
irsend.sendNEC(0xF740BF, 32); // telecomando a 24 bottoni
}
if ((IRsentcode > 100) && (IRsentcode < 200 )) //BLU
{
irsend.sendNEC(0xF7609F, 32); // telecomando a 24 bottoni
}
if ((IRsentcode > 200) && (IRsentcode < 300 )) //LIGH BLU
{
irsend.sendNEC(0xF750AF, 32); // telecomando a 24 bottoni
}
if ((IRsentcode > 400) && (IRsentcode < 500 )) // VIOLET
{
irsend.sendNEC(0xF7708F, 32); // telecomando a 24 bottoni
}
if ((IRsentcode > 500) && (IRsentcode < 600 )) // GREEN
{
irsend.sendNEC(0xF7A05F, 32); // telecomando a 24 bottoni
}
if ((IRsentcode > 600) && (IRsentcode < 700 )) // YELLOW
{
irsend.sendNEC(0xF728D7, 32); // telecomando a 24 bottoni
}
if ((IRsentcode > 700) && (IRsentcode < 800 )) // ORANGE
{
irsend.sendNEC(0xF710EF, 32); // telecomando a 24 bottoni
}
if ((IRsentcode > 800) && (IRsentcode < 900 )) // RED
{
irsend.sendNEC(0xF720DF, 32); // telecomando a 24 bottoni
}
}
// ========LOOP
void setup()
{
Serial.begin(115200);
irsend.begin();
Blynk.begin(auth, ssid, pass);
Blynk.syncAll();
}
void loop()
{
Blynk.run();
testingTimer.run();
}