Created
June 26, 2017 18:50
-
-
Save pudelosha/f84de35698b59b3526483f60a1fb2be7 to your computer and use it in GitHub Desktop.
Wemos D1 R2 WiFi directly controlled from Android application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// based on YouTube tutorial posted by Youtechnoid | |
#include <ESP8266WiFi.h> | |
#include <WiFiClient.h> | |
#include <ESP8266WebServer.h> | |
const char *ssid = "ArduinoGreen"; | |
const char *pass = "LGBTQWERTY"; | |
String command; | |
ESP8266WebServer server(80); | |
void respond(){ | |
server.send(200,"text/html","<h1>Hello ArduinoGreen</h1>"); | |
} | |
void setup() { | |
Serial.begin(9600); | |
pinMode(BUILTIN_LED,OUTPUT); | |
Serial.println(" Initialising"); | |
WiFi.softAP(ssid,pass); | |
IPAddress IPserver = WiFi.softAPIP(); | |
Serial.println(" IP address server : "); | |
Serial.println(IPserver); | |
server.on("/",respond); | |
server.begin(); | |
server.onNotFound([](){ | |
command=server.uri(); | |
server.send(200,"text/plain",command); | |
}); | |
} | |
void loop() { | |
server.handleClient(); | |
if(command.equals("/turnoff")){ | |
digitalWrite(BUILTIN_LED,HIGH); | |
} | |
if(command.equals("/turnon")){ | |
digitalWrite(BUILTIN_LED,LOW); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment