#include #include // WiFi credentials const char* ssid = "Muensel"; const char* password = "Team_Muensel123"; // Button pins const int BUTTON1_PIN = D0; const int BUTTON2_PIN = D2; WebServer server(80); bool buttonPressed = false; int lastPressedButton = 0; // Webpage HTML with permission request const char INDEX_HTML[] PROGMEM = R"rawliteral( Simple Speech Assistant

Speech Assistant

Please enable speech synthesis
)rawliteral"; void setup() { Serial.begin(115200); // Initialize buttons with pull-up resistors pinMode(BUTTON1_PIN, INPUT_PULLUP); pinMode(BUTTON2_PIN, INPUT_PULLUP); // Connect to WiFi Serial.print("Connecting to WiFi"); WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println("\nWiFi Connected!"); Serial.print("IP Address: "); Serial.println(WiFi.localIP()); // Set up web server routes server.on("/", HTTP_GET, []() { server.send(200, "text/html", INDEX_HTML); }); server.on("/button", HTTP_GET, []() { String json; if (buttonPressed) { json = "{\"pressed\":true,\"button\":" + String(lastPressedButton) + "}"; buttonPressed = false; } else { json = "{\"pressed\":false,\"button\":0}"; } server.send(200, "application/json", json); }); server.begin(); Serial.println("Web server started"); } void loop() { server.handleClient(); // Check buttons if (digitalRead(BUTTON1_PIN) == LOW) { buttonPressed = true; lastPressedButton = 1; Serial.println("Button 1 pressed"); delay(50); // Simple debounce } if (digitalRead(BUTTON2_PIN) == LOW) { buttonPressed = true; lastPressedButton = 2; Serial.println("Button 2 pressed"); delay(50); // Simple debounce } }