#define BLYNK_TEMPLATE_ID "TMPL61MmqLL60"
#define BLYNK_TEMPLATE_NAME "LED BUZZER"
#define BLYNK_AUTH_TOKEN "CXVMRTsSd4X4hliD3e2nD3Ns-7U9-TNO"
#include <WiFi.h> // Include the ESP32 WiFi library
#include <BlynkSimpleEsp32.h> // Include the Blynk library for ESP32
#include <LiquidCrystal.h> // Include the LiquidCrystal library
#define BLYNK_PRINT Serial
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
#define LED_PIN 2 // Define the LED pin as D2 for ESP32
#define BUZZER_PIN 4 // Define the buzzer pin as D4 for ESP32
LiquidCrystal lcd(12, 13, 14, 15, 16, 17); // Initialize the LCD with pin connections
BlynkTimer timer;
void setup() {
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
pinMode(LED_PIN, OUTPUT); // Set LED pin as output
pinMode(BUZZER_PIN, OUTPUT); // Set buzzer pin as output
// Initialize the LCD
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("Ready to start...");
}
void loop() {
Blynk.run();
timer.run();
}
BLYNK_WRITE(V0) {
int ledStatus = param.asInt();
if (ledStatus == 1) {
digitalWrite(LED_PIN, HIGH); // Turn on the LED
Blynk.virtualWrite(V1, "Access Granted"); // Send message to Blynk app
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Access Granted"); // Display "Access Granted" on the LCD
}
}
BLYNK_WRITE(V2) {
int buzzerStatus = param.asInt();
if (buzzerStatus == 1) {
digitalWrite(BUZZER_PIN, HIGH); // Turn on the buzzer
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Access Denied"); // Display "Access Denied" on the LCD
} else {
digitalWrite(BUZZER_PIN, LOW); // Turn off the buzzer
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Ready to start..."); // Display default message on the LCD
}
}