Motion Detector with Visual Alert
Introduction
Project made by Ghita Anita-Raluca, 334CB.
A brief overview of the project:
This project detects motion using a PIR sensor and alerts the user through LEDs and an LCD display.
The purpose is to simulate a simple, cheap and effective motion-activated silent alarm.
It’s useful for personal learning and practical applications like basic surveillance.
General Description
Block diagram:
Block diagram description:
PIR Sensor (GPIO): Detects motion and sends digital signal to Arduino.
Arduino UNO R3: Central controller that reads the sensor and drives the outputs.
Potentiometer (ADC): Sets the alert duration and the time before it checks again.
LEDs (GPIO): Green = idle, Red = motion detected.
LCD 16×2 (I2C): Displays status messages via I2C.
Hardware Design
Bill of Materials
Pin Connections
D2 – PIR sensor input: receives the digital signal from the sensor (HIGH = motion detected).
D3 – Red LED output: lights up when motion is detected.
D4 – Green LED output: stays ON when system is idle (no motion).
A0 – Potentiometer: analog input to set delay duration for alert (LED ON time).
A4 (SDA) and A5 (SCL) – I2C communication for the LCD 1602 module.
Hardware Functionality Description
The system uses an Arduino UNO R3 board connected with several components to detect motion and respond visually.
The PIR motion sensor detects movement and sends a HIGH signal to pin D2.
The red LED (D3) turns ON when motion is detected.
The green LED (D4) indicates idle state.
A potentiometer connected to A0 adjusts how long the green LED stays ON (between 1 and 9 seconds).
The LCD (connected via I2C to A4 and A5) displays real-time status messages.
All components are powered via the Arduino’s 5V and GND pins, using a breadboard and jumper wires for interconnection.
Schematics:
Software Design
Used Libraries
Wire.h – for I²C communication with the 16×2 LCD.
LiquidCrystal_I2C.h – for displaying messages on the LCD screen.
No additional libraries are required for the PIR sensor, LEDs, or the potentiometer – native digital and analog pins are used.
Structures and Algorithms
Structures:
Global variables for system state: `motionDetected`, `alertStartTime`.
`int alertDuration` – alert duration in milliseconds, calculated from the potentiometer reading.
`bool ledState` – tracks the state of the red LED.
Algorithms:
PIR motion detection: when motion is detected, the PIR sensor sends a HIGH signal to a digital input pin.
Timing with millis(): the moment of detection is stored using `alertStartTime = millis()`, and the red LED remains ON until `millis() - alertStartTime > alertDuration`.
LCD display update: messages such as “No motion” or “Motion detected” are dynamically updated using functions from the LiquidCrystal_I2C library.
Potentiometer reading: analogRead is used to obtain a value between 0–1023, which is mapped to a duration range (e.g., 0–10000 ms).
LED control logic: the green LED indicates idle mode, the red LED is ON when motion is detected.
Implemented Functions