Hi all,
I am having some problems with my code. I am trying to make a RGB led controller with brightness control. I have managed to change the brightness of each colour individual. But I can’t get the master brightness control (a slider (V0)) to work. Any help would be great.
NodeMCU
Android app
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "**********";
char ssid[] = "**********";
char pass[] = "**********";
int Red = 5;
int Green = 4;
int Blue = 0;
int BrightData;
int RedData;
int GreenData;
int BlueData;
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
pinMode(Red, OUTPUT);
pinMode(Green, OUTPUT);
pinMode(Blue, OUTPUT);
}
BLYNK_WRITE(V0) //Brightness
{
int BrightData = param.asInt();
}
BLYNK_WRITE(V1) //Red
{
int RedData = param.asInt();
analogWrite(Red, RedData);
}
BLYNK_WRITE(V2) //Green
{
int GreenData = param.asInt();
analogWrite(Green, GreenData);
}
BLYNK_WRITE(V3) //Blue
{
int BlueData = param.asInt();
analogWrite(Blue, BlueData);
}
void loop()
{
Blynk.run();
}