#include <LiquidCrystal.h>
const int pirPin = 2; // PIR sensor pin
int count = 0; // Counter variable
LiquidCrystal lcd(8, 9, 4, 5, 6, 7); // LCD pins
void setup() {
pinMode(pirPin, INPUT);
lcd.begin(16, 2);
}
void loop() {
if (digitalRead(pirPin) == HIGH) { // If motion detected
count++; // Increment count
displayCount(); // Update LCD display
delay(1000); // Delay to debounce
}
}
void displayCount() {
lcd.clear(); // Clear previous display
lcd.setCursor(0, 0);
lcd.print("Count: ");
lcd.print(count);
}