📚 Course contents

Projects Hub, build 30 of 81

PIR Motion Alert with LCD Display (Arduino)

intermediate3 min read

Introduction

In today's rapidly evolving world, security has become a primary concern for many homeowners and businesses. Every motion-activated security camera has two parts: one that notices that somebody moved, and one that takes the picture. In this project we will build the first part using Arduino: a motion detector that shows a message on an LCD.

An Arduino Uno does not have the memory or the speed for a camera. When you want to take pictures too, you need a board with a camera, such as the ESP32-CAM.

Working Principle

Every warm body gives out infrared light that we cannot see. The PIR (Passive Infrared) sensor notices when that infrared changes in front of it and sends a HIGH signal to the Arduino. The Arduino then displays "Motion Detected!" on the LCD screen for 2 seconds.

Things We Need

  1. Arduino Uno: To read the sensor and control the display.
  2. PIR (Passive Infrared) Motion Sensor: To detect motion.
  3. 16x2 LCD Display with I2C Module: To provide real-time feedback.
  4. Breadboard and jumper wires: For assembling the circuit.

Working of the System with Arduino

  1. Setting up the PIR Sensor: Connect the sensor's VCC and GND pins to 5V and GND on the Arduino. The sensor's OUT pin is connected to digital pin 2.
  2. Connecting the LCD: Connect VCC to 5V, GND to GND, SDA to A4 and SCL to A5.
  3. Coding the Arduino: The program reads the PIR sensor and, when there is motion, displays the message on the LCD.
Loading the circuit…Arduino Uno
Press Run to upload the code to the Arduino.Open in Lab

Arduino Code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
 
LiquidCrystal_I2C lcd(0x27, 16, 2);  // Set the LCD address and dimensions
 
const int pirPin = 2;  // PIR sensor input pin
bool motionDetected = false;
 
void setup() {
  lcd.init();                      // Initialize the LCD
  lcd.backlight();
  pinMode(pirPin, INPUT);
  Serial.begin(9600);
}
 
void loop() {
  motionDetected = digitalRead(pirPin);
 
  if (motionDetected) {
    // Show the message on the LCD
    lcd.setCursor(0, 0);
    lcd.print("Motion Detected!");
    delay(2000);  // Display the message for 2 seconds
    lcd.clear();
  }
}

Conclusion

You have built the motion detecting half of a security system. You can now add a buzzer, a light or a relay that switches on with the message. Remember to adhere to local laws and regulations when using surveillance equipment.