diff --git a/arduino code b/arduino code new file mode 100644 index 0000000..a482dd4 --- /dev/null +++ b/arduino code @@ -0,0 +1,121 @@ +// this code for testing wifi access point control +// www.dcmote.duino,lk +// coding by Tharindu Ireshana : Leader of DCmote Open Sourse Project +// www.facebook.com/dcremote +// https://github.com/irashana +// www.facebook.com/tharinduireshana +// tirashana@gmail.com +// 94715376785 + + +#include +#include +#include + +/* Set these to your desired credentials. */ +const char *ssid = "DCmoteAP2"; +const char *password = "dcmoteap2"; + +ESP8266WebServer server(80); + +const String HTTP_HEAD = "{v}"; +const String HTTP_STYLE = ""; +const String HTTP_SCRIPT = ""; +const String HTTP_HEAD_END = "
"; + +const String HOMEPAGE = "




"; + + + + + + + +/* Just a little test message. Go to http://192.168.4.1 in a web browser + * connected to this access point to see it. + */ +void handleRoot() { + String s =HTTP_HEAD; + s += HTTP_STYLE; + s += HTTP_SCRIPT; + s += HTTP_HEAD_END; + s += "

www.dcmote.duino.lk

"; + s+=HOMEPAGE; + server.send(200, "text/html", s); + +} + +void cmd1() { + String s =HTTP_HEAD; + s += HTTP_STYLE; + s += HTTP_SCRIPT; + s += HTTP_HEAD_END; + s += "

www.dcmote.duino.lk

"; + s+=HOMEPAGE; + server.send(200, "text/html", s); + digitalWrite(D0,HIGH); +} +void cmd2() { + String s =HTTP_HEAD; + s += HTTP_STYLE; + s += HTTP_SCRIPT; + s += HTTP_HEAD_END; + s += "

www.dcmote.duino.lk

"; + s+=HOMEPAGE; + server.send(200, "text/html", s); + digitalWrite(D1,HIGH); +} +void cmd3() { + String s =HTTP_HEAD; + s += HTTP_STYLE; + s += HTTP_SCRIPT; + s += HTTP_HEAD_END; + s += "

www.dcmote.duino.lk

"; + s+=HOMEPAGE; + server.send(200, "text/html", s); + digitalWrite(D2,HIGH); +} +void cmd4() { + String s =HTTP_HEAD; + s += HTTP_STYLE; + s += HTTP_SCRIPT; + s += HTTP_HEAD_END; + s += "

www.dcmote.duino.lk

"; + s+=HOMEPAGE; + server.send(200, "text/html", s); + digitalWrite(D0,LOW); + digitalWrite(D1,LOW); + digitalWrite(D2,LOW); + +} + +void setup() { + delay(1000); + pinMode(D0,OUTPUT); + pinMode(D1,OUTPUT); + pinMode(D2,OUTPUT); + + digitalWrite(D0,LOW); + + Serial.begin(115200); + Serial.println(); + Serial.print("Configuring access point..."); + /* You can remove the password parameter if you want the AP to be open. */ + WiFi.softAP(ssid, password); + + IPAddress myIP = WiFi.softAPIP(); + Serial.print("AP IP address: "); + Serial.println(myIP); + server.on("/", handleRoot); + server.on("/cmd1", cmd1); + server.on("/cmd2", cmd2); + server.on("/cmd3", cmd3); + server.on("/cmd4", cmd4); + + server.begin(); + Serial.println("HTTP server started"); +} + +void loop() { + server.handleClient(); +}