#define BLYNK_TEMPLATE_ID "TMPL68A9yYRtL"
#define BLYNK_TEMPLATE_NAME "ESP32 with 2 LED"
#define BLYNK_AUTH_TOKEN "h_0Z-HwmjdWuwAFqQKwxt9FSHdSaIwVk"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
// Replace these credentials with your own
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
// Pins for the LEDs
#define RED_LED_PIN 2
#define BLUE_LED_PIN 4
// Blynk virtual pins
#define RED_LED_VPIN V0
#define BLUE_LED_VPIN V1
void setup() {
Serial.begin(115200);
pinMode(RED_LED_PIN, OUTPUT);
pinMode(BLUE_LED_PIN, OUTPUT);
Blynk.begin(auth, ssid, pass);
}
void loop() {
Blynk.run();
}
// Callback function for controlling the red LED
BLYNK_WRITE(RED_LED_VPIN) {
int redLedState = param.asInt();
digitalWrite(RED_LED_PIN, redLedState);
}
// Callback function for controlling the blue LED
BLYNK_WRITE(BLUE_LED_VPIN) {
int blueLedState = param.asInt();
digitalWrite(BLUE_LED_PIN, blueLedState);
}