#include <LiquidCrystal.h>
int inputPin = A0;
int ledPin = 7;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // Initialize LCD with pin mapping
void setup() {
Serial.begin(9600);
pinMode(inputPin, INPUT);
pinMode(ledPin, OUTPUT);
lcd.begin(16, 2); // Initialize LCD as a 16x2 display
lcd.print("Hello, LCD!"); // Display some initial text
delay(2000); // Wait for 2 seconds
}
void loop() {
lcd.clear(); // Clear the LCD screen
if (digitalRead(inputPin)==HIGH)
{
digitalWrite(ledPin, HIGH);
lcd.print("Motion detected!");
}
else
{
digitalWrite(ledPin, LOW);
lcd.print("Motion not detected!");
}
delay(5000);
}