I am making a security motion detection system with an Arduino Uno R3 and a PIR sensor for my final school project (PYP), and when motion is detected, the LED and buzzer are supposed to do their own things, and the LCD is supposed to show an alert. I inserted the following code in the IDE and simulated the circuit in TinkerCAD successfully (schematic and diagram below):
#include <LiquidCrystal.h>
LiquidCrystal lcd(13, 12, 6, 5, 3, 2);
int led = 7;
int PIR = 4;
int buzzer = 8;
int PIRstatus;
void setup() {
lcd.begin(16, 2);
pinMode(led, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(PIR, INPUT);
lcd.clear();
}
void loop() {
PIRstatus = digitalRead(PIR);
if (PIRstatus == HIGH) {
lcd.clear();
digitalWrite(led, HIGH);
digitalWrite(buzzer, HIGH);
tone(buzzer, 200, 2000); //tone(pin, frequency, Duration
lcd.setCursor(0, 1);
lcd.print("ALERT! CRIME!");
delay(6000);
lcd.clear();
} else {
lcd.setCursor(0, 0);
lcd.print("SECURE");
digitalWrite(led, LOW);
digitalWrite(buzzer, LOW);
}
delay(1000);
}
I've already made sure to do everything precisely. However, when I uploaded the code and plugged the Arduino into my computer, the LED, piezo buzzer, and LCD just followed the code even if no motion was detected. I can confirm that they are not dependent on the PIR sensor for some reason because I disconnected the PIR sensor, yet the Arduino kept on reading HIGH.
Any advice or support offered is greatly appreciated, and I'm sorry if my question is probably relatively simpler compared to other topics, as I am still very new in all this technological hardware stuff. If a picture of the actual circuit is needed, I'm able to take a photo and send it. Once again, thank you.








