How To Control Light Using by IP Address

 


Code :- 

// Code Started
// This Code Created By Technical idEas(YT)
// Light Control Using IP address

#include <ESP8266WiFi.h>

WiFiClient client;

WiFiServer server(80);

#define led D5

void setup()

{

  // put your setup code here, to run once:

  Serial.begin(9600);

  WiFi.begin("Sam", "12345678");

  while(WiFi.status() != WL_CONNECTED)

  {

    delay(200);

    Serial.print("..");

  }

  Serial.println();

  Serial.println("NodeMCU is connected!");

  Serial.println(WiFi.localIP());

  server.begin();

  pinMode(led, OUTPUT);

}

void loop()

{

  // put your main code here, to run repeatedly:

  client = server.available(); //Gets a client that is connected to the server and has data available for reading.

  if (client == 1)

  {

    String request = client.readStringUntil('\n');

    Serial.println(request);

    request.trim();

    if(request == "GET /ledon HTTP/1.1")

    {

      digitalWrite(led, HIGH);

    }

    if(request == "GET /ledoff HTTP/1.1")

    {

      digitalWrite(led, LOW);

    }

  }

}




Download Zip File :- https://drive.google.com/file/d/19_t2dHn-LyiorCzzF2xZzRmmwV8K8Ity/view?usp=drivesdk


Subscribe Now :- https://youtube.com/channel/UCCJyR_wnt3SxhErsSUP9Wrw

Comments

Popular posts from this blog

Servo Motor Control Using By Bluetooth HC-05

Best IOT Project By Technical idEas