nodemcu project

                                                   
                                    
                          Nodemcu project  


            

                                   
     arduino cording

/////////////////////////////////
// Generated with a lot of love//
// with TUNIOT FOR ESP8266     //
// Website: Easycoding.tn      //
/////////////////////////////////
//Header Library
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Define SSID, PASSWORD & PORT
const char *ssid = "Group51"; const char *password ="sandip007";
ESP8266WebServer server(80);
///////////////////////////////////////////////////////////////////////////////
//Get responce from Page and Code for Forward/Reverse/Left/Right Motion
void handleRoot() {response();}
   void ON1()   {digitalWrite(13,HIGH);
                 delay(100);
                 digitalWrite(13,LOW);
                 digitalWrite(12,HIGH);
                 delay(30);
                 digitalWrite(12,LOW);
                 digitalWrite(14,HIGH);
                 delay(100);
                 digitalWrite(14,LOW);
                 digitalWrite(2,HIGH);
                 delay(30);
                 digitalWrite(2,LOW);
                 digitalWrite(0,HIGH);
                 delay(100);
                 digitalWrite(0,LOW);
                 digitalWrite(4,HIGH);
                 delay(30);
                 digitalWrite(4,LOW);
                 digitalWrite(5,HIGH);
                 delay(100);
                 digitalWrite(5,LOW);
                 digitalWrite(16,HIGH);
                 delay(30);
                 digitalWrite(16,LOW);
                 response();}//up
  
  
      void ON2()  { digitalWrite(16,HIGH);
                    delay(10);
                    digitalWrite(16,LOW);
                    digitalWrite(5,HIGH);
                    delay(40);
                    digitalWrite(5,LOW);
                    digitalWrite(4,HIGH);
                    delay(10);
                    digitalWrite(4,LOW);
                    digitalWrite(0,HIGH);
                    delay(30);
                    digitalWrite(0,LOW);
                    digitalWrite(2,HIGH);
                    delay(10);
                    digitalWrite(2,LOW);
                    digitalWrite(14,HIGH);
                    delay(40);
                    digitalWrite(14,LOW);
                    digitalWrite(12,HIGH);
                    delay(10);
                    digitalWrite(12,LOW);
                    digitalWrite(13,HIGH);
                    delay(30);
                    digitalWrite(13,LOW);
                    response();}//Down
  
 void ON3() { digitalWrite(16,HIGH);
             delay(100);
             digitalWrite(16,LOW);
             digitalWrite(5,HIGH);
             delay(100);
             digitalWrite(5,LOW);
             digitalWrite(4,HIGH);
             delay(100);
             digitalWrite(4,LOW);
             digitalWrite(0,HIGH);
             delay(100);
             digitalWrite(0,LOW);
             digitalWrite(2,HIGH);
             delay(100);
             digitalWrite(2,LOW);
             digitalWrite(14,HIGH);
             delay(100);
             digitalWrite(14,LOW);
             digitalWrite(12,HIGH);
             delay(100);
             digitalWrite(12,LOW);
             digitalWrite(13,HIGH);
             delay(100);
             digitalWrite(13,LOW);
             response();}//Right
  
    void ON4()  { digitalWrite(16,HIGH);
                   delay(1000);
                   digitalWrite(5,HIGH);
                   delay(30);
                   digitalWrite(4,HIGH);
                   delay(1000);
                   digitalWrite(0,HIGH);
                   delay(30);
                   digitalWrite(2,HIGH);
                   delay(1000);
                   digitalWrite(14,HIGH);
                   delay(300);
                   digitalWrite(12,HIGH);
                   delay(1000);
                   digitalWrite(13,HIGH);
                   delay(30);
                   digitalWrite(16,LOW);
                   digitalWrite(5,LOW);
                   digitalWrite(4,LOW);
                   digitalWrite(0,LOW);
                   digitalWrite(2,LOW);
                   digitalWrite(14,LOW);
                   digitalWrite(12,LOW);
                   digitalWrite(13,LOW);
                   delay(1000); 
                   response();}//LEFT
  
   void OFF()   { digitalWrite(16,LOW);
                  digitalWrite(5,LOW);
                  digitalWrite(4,LOW);
                  digitalWrite(0,LOW);
                  digitalWrite(2,LOW);
                  digitalWrite(14,LOW);
                  digitalWrite(12,LOW);
                  digitalWrite(13,LOW);
                  response();}
   /////////////////////////////////////////////////////////////////////////////////
  //Code to generate HTML Page
     const String HtmlHtml = "<html><head>"
     "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" /></head>";
     const String HtmlHtmlClose = "</html>";
     const String HtmlButtons =
        "<a href=\"OFF\"><button style=\"display: block; width: 50%;\">OFF</button></a><br/>"
        "<a href=\"ON1\"><button style=\"display: block; width: 50%;\">ON1</button></a><br/>"
        "<a href=\"ON2\"><button style=\"display: block; width: 50%;\">ON2</button></a><br/>"
        "<a href=\"ON3\"><button style=\"display: block; width: 50%;\">ON3</button></a><br/>"
        "<a href=\"ON4\"><button style=\"display: block; width: 50%;\">ON4</button></a><br/>";
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//HTML Responce from URL
void response(){
  String htmlRes = HtmlHtml ;
  htmlRes += HtmlButtons;
  htmlRes += HtmlHtmlClose;
  server.send(200, "text/html", htmlRes);
  delay(100);
}
///////////////////////////////////////////////////////////////////////////////////////
void setup() {
   delay(1000);
  //////////////////////////////////////////////////////////////////////////////////
  //define pin as out pins
    pinMode(16, OUTPUT);
    pinMode(5, OUTPUT);
    pinMode(4, OUTPUT);
    pinMode(0, OUTPUT);
    pinMode(2, OUTPUT);
    pinMode(14, OUTPUT);
    pinMode(12, OUTPUT);
    pinMode(13, OUTPUT);
    /////////////////////////////////////////////////////////////////////
  digitalWrite(16,LOW);
  digitalWrite(5,LOW);
  digitalWrite(4,LOW);
  digitalWrite(0,LOW);
  digitalWrite(2,LOW);
  digitalWrite(14,LOW);
  digitalWrite(12,LOW);
  digitalWrite(13,LOW);
  Serial.begin(9600);
  //////////////////////////////////////////////////////////////////////////////////////
  // To create WiFi Access Point
    WiFi.softAP(ssid, password);
    IPAddress apip = WiFi.softAPIP();
    Serial.print("visit: \n");
    Serial.println(apip);
//////////////////////////////////////////////////////////////////////////////////////////////////////////// 
//Action triggered by Page
    server.on("/", handleRoot);
    server.on("/OFF", OFF);
    server.on("/ON1", ON1);
    server.on("/ON2", ON2);
    server.on("/ON3", ON3);
    server.on("/ON4", ON4);
    server.begin();
    Serial.println("HTTP server beginned");
////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
void loop() {
  server.handleClient();
  }

Comments