Please help us figure this out. Thank you!
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <DNSServer.h>
MDNSResponder mdns;
// Replace with your network credentials
const char* ssid = "xxxxxx";
const char* password = "xxxxxx";*/
ESP8266WebServer server(80);
String webPage = "";
int gpio5_pin = 5;
void setup(void){
digitalWrite(gpio5_pin, HIGH);
delay(2000);
WiFi.softAP(ssid, password);
IPAddress myIP = WiFi.softAPIP();
Serial.println(myIP);
webPage += "<HTML>";
webPage += "<HEAD>";
webPage += "<TITLE>LED</TITLE>";
webPage += "</HEAD>";
webPage += "<BODY>";
webPage += "<H1>LED1</H1>";
webPage += "<a href=\"ON1\"><button>ON1</button></a> <a href=\"OFF1\"><button>OFF1</button></a></p>";
webPage += "<H1>LED2</H1>";
webPage += "<a href=\"ON2\"><button>ON2</button></a> <a href=\"OFF2\"><button>OFF2</button></a></p>";
webPage += "<BODY/>";
webPage += "</HTML>";
// preparing GPIOs
pinMode(gpio5_pin, OUTPUT);
digitalWrite(gpio5_pin, LOW);
delay(1000);
Serial.begin(115200);
//WiFi.begin(ssid, password);
Serial.println("");
server.on("/", [](){
server.send(200, "text/html", webPage);
Serial.println("HELLO");
});
server.on("/ON1", [](){
server.send(200, "text/html", webPage);
digitalWrite(gpio5_pin, HIGH);
delay(1000);
});
server.on("/OFF1", [](){
server.send(200, "text/html", webPage);
digitalWrite(gpio5_pin, LOW);
delay(1000);
});
server.on("/ON2", [](){
server.send(200, "text/html", webPage);
digitalWrite(14, HIGH);
delay(1000);
});
server.on("/OFF2", [](){
server.send(200, "text/html", webPage);
digitalWrite(14, LOW);
delay(1000);
});
server.begin();
Serial.println("HTTP server started");
}
void loop(void){
server.handleClient();
}