#include <BlynkSimpleEsp32.h>
#define BLYNK_TEMPLATE_ID "TMPL2HqC_hUr3"
#define BLYNK_TEMPLATE_NAME "Led"
#define BLYNK_AUTH_TOKEN "o1kYPAbHT5W3rS41SY3_GF64oT6NyHHI"
// Define the LED pins
int led1 = 21;
int led2 = 22;
int led3 = 23;
// Blynk authorization token
char auth[] = BLYNK_AUTH_TOKEN;
// WiFi credentials
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
BlynkTimer timer;
// This function will be called every time a widget in the Blynk app writes to Virtual Pin 0
BLYNK_WRITE(V0) {
int buttonState = param.asInt();
digitalWrite(led1, buttonState);
}
// This function will be called every time a widget in the Blynk app writes to Virtual Pin 1
BLYNK_WRITE(V1) {
int buttonState = param.asInt();
digitalWrite(led2, buttonState);
}
// This function will be called every time a widget in the Blynk app writes to Virtual Pin 2
BLYNK_WRITE(V2) {
int buttonState = param.asInt();
digitalWrite(led3, buttonState);
}
void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
Serial.begin(115200);
Serial.println("Connecting to Blynk...");
Blynk.begin(auth, ssid, pass);
if (Blynk.connected()) {
Serial.println("Connected to Blynk!");
} else {
Serial.println("Failed to connect to Blynk.");
}
}
void loop() {
Blynk.run();
timer.run();
}