lcd and esp32 with motion sensor — ESP32 simulation

An interactive ESP32 circuit simulation you can run free in your browser on Velxio, by vishwesvaran52.

Components

Sketch code

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
int MOTION =2;
int LED=4;
void setup() {
  pinMode(MOTION, INPUT);
  pinMode(LED, OUTPUT);
  lcd.init();
  lcd.backlight();
}

void loop() {
  int Sensorvalue=digitalRead(MOTION);
  if(Sensorvalue==HIGH)
  {
    digitalWrite(LED, HIGH);
  lcd.setCursor(0, 0);
  lcd.print("MOTION");
  lcd.setCursor(0, 1);
  lcd.print("DETECTED");
  delay(2000);
  lcd.clear();
  }
    else{
      digitalWrite(LED, LOW);
  lcd.setCursor(0, 0);
  lcd.print("NOT");
  lcd.setCursor(0, 1);
  lcd.print("DETECTED");
  delay(2000);
  lcd.clear();
    }
  }

More projects by vishwesvaran52