I'm sorry, here's the Arduino code, sir.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#define IR D6 // connect ir sensor to nodemcu pin D5
#define RedLED 14 // connect LED to nodemcu pin D3
#define GreenLED 2 // connect LED to nodemcu pin D7
String page = "";
bool data;
int slot1; // Parking slot 1
String command;
const char* ssid = "TP-LINK_M5_D79F4C"; // WiFi Name
const char* password = "10250712"; // WiFi Password
ESP8266WebServer server(80);
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Declaration of LCD
void setup() {
Serial.begin(9600);
pinMode(IR, INPUT); // Sensor pin INPUT
pinMode(RedLED, OUTPUT); // LED pin OUTPUT
pinMode(GreenLED, OUTPUT); // LED pin OUTPUT
//Start WiFi connection
WiFi.disconnect();
delay(2000);
Serial.println();
Serial.print("Wifi connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
Serial.println();
Serial.print("Connecting");
while( WiFi.status() != WL_CONNECTED )
{
delay(500);
Serial.print(".");
}
Serial.println();
Serial.println("Wifi Connected!");
Serial.print("NodeMCU IP Address: ");
Serial.println(WiFi.localIP() );
// Starting WEB-server
server.on ( "/", HTTP_handleRoot );
server.onNotFound ( HTTP_handleRoot );
server.begin();
// Start displaying on LCD
lcd.begin(16, 2); // LCD 16 columns and 2 rows
lcd.print("Smart Parking"); // Print on first row of LCD
delay(10);
lcd.setCursor(0, 1); // Move the cursor to the next line and print
lcd.print("System");
delay(1000);
lcd.clear();
Serial.println("Starting Project......");
Serial.println();
}
void loop() {
slot1 = digitalRead (IR);
delay(500);
//read the sensor and light up the LED
//vacant(green), occupied(red)
server.handleClient();
command = server.arg("State");
if (slot1 == 1) {
digitalWrite(RedLED, HIGH);
digitalWrite(GreenLED, LOW);
lcd.setCursor(1, 0); // Move the cursor to the next line and print
lcd.print("Slot 1: 0");
delay(500);
}
else
{
digitalWrite(GreenLED, HIGH);
digitalWrite(RedLED, LOW); // LED LOW
lcd.setCursor(1, 0);
lcd.print("Slot 1: 1");
delay(100);
}
}
void HTTP_handleRoot(void)
{
page = "<h1>Sensor to Node MCU Web Server</h1><h3>Data:</h3> <h4>"+String(data)+"</h4>";
server.send ( 200, "text/html", page );
delay(1);
}