#define BLYNK_TEMPLATE_NAME "HOME AUTOMATION"
#define BLYNK_AUTH_TOKEN "gUE-BwZWFe6x6Zeyk-G4UgNdiQSBgVY_"
#define BLYNK_TEMPLATE_ID "TMPL3u50qrPHF"
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
// Your Blynk Authentication Token
char auth[] = BLYNK_AUTH_TOKEN;
// Your WiFi credentials
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
// Define the pin where the LED is connected
const int ledPin = 16;
void setup() {
// Debug console
Serial.begin(115200);
// Initialize the Blynk library
Blynk.begin(auth, ssid, pass);
// Set the LED pin as output
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
}
void loop() {
// Run the Blynk run function
Blynk.run();
}
// BLYNK_WRITE function to handle the button widget
BLYNK_WRITE(V1) {
int pinValue = param.asInt(); // Get the value from the app (0 or 1)
Serial.println(pinValue);
if (pinValue == 1) {
digitalWrite(ledPin, HIGH); // Turn the LED on
} else {
digitalWrite(ledPin, LOW); // Turn the LED off
}
}