Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ESP8266WiFi.h>
- #include <ESP8266WebServer.h>
- #include <ESP8266mDNS.h>
- const char *ssid = "DataJugling";
- const char *password = "jugle123";
- const char *mDNS = "dataserver";
- ESP8266WebServer server(80);
- bool ledState = LOW;
- String getData() {
- return String("{\"state\": ") + String(ledState) + String("}");
- }
- void setup() {
- WiFi.mode(WIFI_AP);
- WiFi.softAP(ssid, password);
- MDNS.begin(mDNS);
- server.on("/", []() {
- server.send(200, "text/html", getData());
- });
- server.begin();
- }
- void loop() {
- server.handleClient();
- if(millis() % 1000 == 0) ledState = !ledState;
- }
Advertisement
Add Comment
Please, Sign In to add comment