#include #include const char* ssid = "Your_Hotspot_Name"; const char* password = "Your_Hotspot_Password"; const int buzzerPin = D2; // Replace with correct GPIO pin if needed bool buzzerState = false; WebServer server(80); void handleRoot() { String html = "ESP32 Buzzer Control"; html += "

ESP32 Buzzer Control

"; html += "

Buzzer is: " + String(buzzerState ? "ON" : "OFF") + "

"; html += " "; html += ""; html += ""; server.send(200, "text/html", html); } void handleOn() { digitalWrite(buzzerPin, HIGH); buzzerState = true; handleRoot(); } void handleOff() { digitalWrite(buzzerPin, LOW); buzzerState = false; handleRoot(); } void setup() { Serial.begin(115200); pinMode(buzzerPin, OUTPUT); WiFi.begin(ssid, password); Serial.println("Connecting to Wi-Fi..."); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println("\nāœ… Connected to Wi-Fi"); Serial.print("šŸ”— IP Address: "); Serial.println(WiFi.localIP()); server.on("/", handleRoot); server.on("/on", handleOn); server.on("/off", handleOff); server.begin(); Serial.println("🌐 Web server started."); } void loop() { server.handleClient(); }