#include <WiFi.h>
#include <WebServer.h>
const char* ssid = "Wokwi-GUEST";
const char* password = "";
WebServer server(80);
int relayPin = 27; // GPIO for relay
void handleRoot() {
String html = "<h1>Voice Assistant Control</h1><p>Use IFTTT or Google Assistant to send HTTP requests.</p>";
server.send(200, "text/html", html);
}
void handleOn() {
digitalWrite(relayPin, HIGH);
server.send(200, "text/html", "<p>Device ON</p>");
}
void handleOff() {
digitalWrite(relayPin, LOW);
server.send(200, "text/html", "<p>Device OFF</p>");
}
void setup() {
Serial.begin(115200);
pinMode(relayPin, OUTPUT);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) delay(500);
Serial.println(WiFi.localIP());
server.on("/", handleRoot);
server.on("/on", handleOn);
server.on("/off", handleOff);
server.begin();
}
void loop() { server.handleClient(); }