第一組

#include <ESP8266WiFi.h> #include <WiFiClient.h> #include <ESP8266WebServer.h> #define LED_PIN D2 const char* ssid = "Hamster"; const char* password = "test1234"; ESP8266WebServer server(80); void setup() { pinMode(D2,OUTPUT); Serial.begin(115200); WiFi.begin(ssid, password); Serial.println(""); // Wait for connection while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.print("Connected to "); Serial.println(ssid); Serial.print("IP address: "); Serial.println(WiFi.localIP()); server.on("/", []() { server.send(200, "text/html", PAGE_INDEX); }); server.on("/LEDOn", []() { digitalWrite(D2, 1); server.send(200, "text/html", PAGE_LEDON); }); server.on("/LEDOff", []() { digitalWrite(D2, 0); server.send(200, "text/html", PAGE_LEDOFF); }); server.begin(); Serial.println("HTTP server started"); } void loop() { server.handleClient(); }

home.h

const char PAGE_INDEX[] PROGMEM = R"=====( )=====";

LEDon.h

const char PAGE_LEDON[] PROGMEM = R"=====( )=====";

LEDoff.h

const char PAGE_LEDOFF[] PROGMEM = R"=====( )=====";