/*************************************************************
Blynk using LED widgets on your phone for 3 LEDs!
App dashboard setup:
LED widget on V1, V2, V3
*************************************************************/
/* Fill-in information from Blynk Device Info here */
#define BLYNK_TEMPLATE_ID "TMPL6Z8vwaWG1"
#define BLYNK_TEMPLATE_NAME "Quickstart Device"
#define BLYNK_AUTH_TOKEN "VXBYSZkohqhii1hlfUfu4DqYWPJL2h-b"
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
// Your WiFi credentials.
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
// Define the GPIO pins connected to the LEDs
#define LED1_PIN 2
#define LED2_PIN 4
#define LED3_PIN 5
// Create LED widget objects for V1, V2, and V3
WidgetLED led1(V1);
WidgetLED led2(V2);
WidgetLED led3(V3);
void setup()
{
// Debug console
Serial.begin(115200);
// Set the GPIO pins as OUTPUT
pinMode(LED1_PIN, OUTPUT);
pinMode(LED2_PIN, OUTPUT);
pinMode(LED3_PIN, OUTPUT);
// Connect to Blynk
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
}
BLYNK_WRITE(V1) {
int pinValue = param.asInt(); // Read the value of the widget
if (pinValue == 1) {
digitalWrite(LED1_PIN, HIGH); // Turn on LED1
Serial.println("LED on V1: on");
} else {
digitalWrite(LED1_PIN, LOW); // Turn off LED1
Serial.println("LED on V1: off");
}
}
BLYNK_WRITE(V2) {
int pinValue = param.asInt(); // Read the value of the widget
if (pinValue == 1) {
digitalWrite(LED2_PIN, HIGH); // Turn on LED2
Serial.println("LED on V2: on");
} else {
digitalWrite(LED2_PIN, LOW); // Turn off LED2
Serial.println("LED on V2: off");
}
}
BLYNK_WRITE(V3) {
int pinValue = param.asInt(); // Read the value of the widget
if (pinValue == 1) {
digitalWrite(LED3_PIN, HIGH); // Turn on LED3
Serial.println("LED on V3: on");
} else {
digitalWrite(LED3_PIN, LOW); // Turn off LED3
Serial.println("LED on V3: off");
}
}
void loop()
{
Blynk.run(); // Run the Blynk process
}