#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "TMPL5Y1oxRxFN"
#define BLYNK_TEMPLATE_NAME "RGB LED"
#define BLYNK_AUTH_TOKEN "LJIJi8KnmAX_68zqYRt2T9ui35QZphz3"
#define R 15
#define G 2
#define B 4
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char ssid []= "Wokwi-GUEST";
char pass []= ""; // open networks
char auth[] = BLYNK_AUTH_TOKEN;
BLYNK_WRITE(V1)
{
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
if (pinValue == 1)
{
analogWrite(R, 255);
}
else {
analogWrite(R, 0);
}
// process received value
//int pinValue = param.asInt();
//digitalWrite(15,pinValue);
}
BLYNK_WRITE(V2)
{
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
if (pinValue == 1)
{
analogWrite(G, 255);
}
else {
analogWrite(G, 0);
}
// process received value
// process received value
//int pinValue = param.asInt();
//digitalWrite(2,pinValue);
}
BLYNK_WRITE(V3)
{
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
if (pinValue == 1)
{
analogWrite(B, 255);
}
else {
analogWrite(B, 0);
}
// process received value
// process received value
//int pinValue = param.asInt();
//digitalWrite(4,pinValue);
}
void setup()
{
// Debug console
Serial.begin(115200);
pinMode(2, OUTPUT);
pinMode(4, OUTPUT);
pinMode(15, OUTPUT);
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
}
void loop()
{
Blynk.run();
}