#define BLYNK_TEMPLATE_ID "TMPL2qV7zqv2B"
#define BLYNK_TEMPLATE_NAME "Smart Door Alert System"
#define BLYNK_AUTH_TOKEN "mL6gVSjyVaGC9EvOgl-ph_nWaYbJK6di"
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
// Replace with your Wi-Fi credentials
const char WIFI_SSID[] = "Wokwi-GUEST";
const char WIFI_PASSWORD[] = "";
// Replace with your Blynk Auth Token
char auth[] = "mL6gVSjyVaGC9EvOgl-ph_nWaYbJK6di";
// Pins for the LEDs
const int LED1_PIN = 15;
const int LED2_PIN = 16;
// Blynk Virtual Pins
#define V1 1
#define V2 2
void setup() {
// Initialize Serial Monitor for debugging
Serial.begin(9600);
// Initialize LED pins
pinMode(LED1_PIN, OUTPUT);
pinMode(LED2_PIN, OUTPUT);
// Connect to Wi-Fi
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nConnected to Wi-Fi");
// Connect to Blynk
Blynk.begin(auth, WIFI_SSID, WIFI_PASSWORD);
}
void loop() {
Blynk.run(); // Run Blynk
}
// Blynk Callbacks for Virtual Pin Control
BLYNK_WRITE(V1) {
int value = param.asInt(); // Get the value from the Blynk app
digitalWrite(LED1_PIN, value); // Control LED1
}
BLYNK_WRITE(V2) {
int value = param.asInt(); // Get the value from the Blynk app
digitalWrite(LED2_PIN, value); // Control LED2
}