#include<LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int led = 13;
int sensor = 7;
int val = 0;
void setup() {
pinMode(led, OUTPUT);
pinMode(sensor, INPUT);
Serial.begin(9600);
lcd.begin(16, 2);
}
void loop(){
val = digitalRead(sensor);
if (val == HIGH) {
digitalWrite(led, HIGH);
delay(100);
Serial.println("Motion detected!");
lcd.setCursor(0,0);
lcd.print("detected");
}
else {
digitalWrite(led, LOW);
delay(200);
Serial.println("Motion stopped!");
lcd.clear();
lcd.setCursor(0,0);
lcd.print("stopped");
delay(100);
}
}