#define BLYNK_TEMPLATE_ID "TMPL3Bxhvat8O"
#define BLYNK_TEMPLATE_NAME "blynk and wokwi project"
#define BLYNK_AUTH_TOKEN "LNO2-t2xtrh31lekJvrA8oLTubE3MrIP"
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
// WiFi credentials
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
// Blynk authentication token
char auth[] = "LNO2-t2xtrh31lekJvrA8oLTubE3MrIP";
// Buzzer pin
#define BUZZER_PIN 2 // Change this to the GPIO pin connected to your buzzer
void setup() {
Serial.begin(115200);
pinMode(BUZZER_PIN, OUTPUT);
// Connect to WiFi
WiFi.begin(ssid, pass);
Serial.print("Connecting to WiFi");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nConnected to WiFi");
// Connect to Blynk
Blynk.begin(auth, ssid, pass);
}
void loop() {
Blynk.run();
}
// Blynk switch state change handler
BLYNK_WRITE(V1) {
int switchState = param.asInt();
if (switchState == HIGH) {
// Turn on the buzzer
digitalWrite(BUZZER_PIN, HIGH);
} else {
// Turn off the buzzer
digitalWrite(BUZZER_PIN, LOW);
}
}