/********* Rui Santos Complete project details at http://randomnerdtutorials.com Edited from original by Alex Hill *********/ #include #include #include #include MDNSResponder mdns; // Replace with your network credentials const char* ssid = "BobsMiFi"; const char* password = "12345678"; const int TIME_IN_MS = 1000; ESP8266WebServer server(80); String webPage = ""; int gpio0_pin = 0; void setup(void){ webPage = page(); // preparing GPIOs pinMode(gpio0_pin, OUTPUT); digitalWrite(gpio0_pin, LOW); delay(1000); 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()); if (mdns.begin("esp8266", WiFi.localIP())) { Serial.println("MDNS responder started"); } server.on("/", [](){ server.send(200, "text/html", webPage); }); server.on("/socket1On", [](){ server.send(200, "text/html", webPage); digitalWrite(gpio0_pin, HIGH); delay(1000); }); server.on("/socket1Off", [](){ server.send(200, "text/html", webPage); digitalWrite(gpio0_pin, LOW); delay(1000); }); //alex test code here server.on("/socket1On1Sec", [](){ server.send(200,"text/html", webPage); digitalWrite(gpio0_pin, HIGH); delay(TIME_IN_MS); digitalWrite(gpio0_pin, LOW); }); server.on("/socket1On2Sec", [](){ server.send(200,"text/html", webPage); digitalWrite(gpio0_pin, HIGH); delay(TIME_IN_MS*2); digitalWrite(gpio0_pin, LOW); }); server.on("/socket1On3Sec", [](){ server.send(200,"text/html", webPage); digitalWrite(gpio0_pin, HIGH); delay(TIME_IN_MS*3); digitalWrite(gpio0_pin, LOW); }); server.on("/socket1On4Sec", [](){ server.send(200,"text/html", webPage); digitalWrite(gpio0_pin, HIGH); delay(TIME_IN_MS*4); digitalWrite(gpio0_pin, LOW); }); server.on("/socket1On5Sec", [](){ server.send(200,"text/html", webPage); digitalWrite(gpio0_pin, HIGH); delay(TIME_IN_MS*5); digitalWrite(gpio0_pin, LOW); }); server.on("/socket1On10Sec", [](){ server.send(200,"text/html", webPage); digitalWrite(gpio0_pin, HIGH); delay(TIME_IN_MS*10); digitalWrite(gpio0_pin, LOW); }); server.on("/socket1On15Sec", [](){ server.send(200,"text/html", webPage); digitalWrite(gpio0_pin, HIGH); delay(TIME_IN_MS*15); digitalWrite(gpio0_pin, LOW); }); server.on("/socket1On20Sec", [](){ server.send(200,"text/html", webPage); digitalWrite(gpio0_pin, HIGH); delay(TIME_IN_MS*20); digitalWrite(gpio0_pin, LOW); }); server.on("/socket1On25Sec", [](){ server.send(200,"text/html", webPage); digitalWrite(gpio0_pin, HIGH); delay(TIME_IN_MS*25); digitalWrite(gpio0_pin, LOW); }); server.on("/socket1On30Sec", [](){ server.send(200,"text/html", webPage); digitalWrite(gpio0_pin, HIGH); delay(TIME_IN_MS*30); digitalWrite(gpio0_pin, LOW); }); server.on("/socket1On60Sec", [](){ server.send(200,"text/html", webPage); digitalWrite(gpio0_pin, HIGH); delay(TIME_IN_MS*60); digitalWrite(gpio0_pin, LOW); }); server.begin(); Serial.println("HTTP server started"); } void loop(void){ server.handleClient(); } char* page() { char* wp = "" "" "" "" "" "" "

Site 17

" "
" "
" "
" "

" " Enter Below:" "

" " " "
" "
" "" "" "" "" "" "
" "
" "" "" "" "" "" "
" "
" "
" "" ""; return wp; }