Friday, 2 March 2018

Running the code


Title : Running code Node MCU:

In this wek i have compile the code and run this code at Arduino Software I have used my phone VIVO to the network connection .From the image below the node MCU is connected to the phone 

Coding :

//http://www.instructables.com/id/NodeMCU-LED-Static-IP/
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>

const char* ssid = "vivo 1713"; // ssid
const char* password = "123456789";// password
//192.168.43.20
IPAddress ip(192, 168, 43, 21); //set static ip
IPAddress gateway(192, 168, 43, 1); //set getteway
IPAddress subnet(255, 255, 255, 0);//set subnet

// defines pins numbers
const int trigPin = D1;
const int echoPin = D2;


// defines variables
long duration;
int distance;
const int Green = D5;
const int Red = D6;
//const int LEDC = 14; // 

String page = "";
String (state);
String (stats);
ESP8266WebServer server(80);

void setup() {
  pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
  pinMode(echoPin, INPUT); // Sets the echoPin as an Input
  pinMode(Green, OUTPUT);
  pinMode(Red, INPUT);
  
  Serial.begin(115200);
  delay(10);


  // Connection to wireless network
  Serial.println();
  Serial.println();
  Serial.print("Connected to ");
  Serial.println(ssid);

  WiFi.config(ip, gateway, subnet);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  
  server.begin();
  Serial.println("Server strted");





:


                                       

No comments:

Post a Comment