🚨 Arduino-Based Intruder Detection System: A Project Guide
This article outlines the design and operation of a cost-effective and efficient intruder detection system using an Arduino Uno as the central microcontroller, a Passive Infrared (PIR) sensor for motion detection, and visual/audible notification via a red LED, a green LED, and a buzzer. This project is ideal for beginners and provides a solid foundation in home security automation.
💡 Core Components and Function
The system operates by continuously monitoring for changes in infrared radiation using the PIR sensor. Any detected movement triggers an alert state, changing the system’s status from ‘Standby’ to ‘Alert’.
Component
Role
Functionality
Arduino Uno
Microcontroller (The Brain)
Processes data from the PIR sensor and controls the state of the LEDs and the buzzer.
PIR Sensor
Motion Detector (The Eyes)
Detects movement of warm objects (like a human) by sensing changes in infrared light. Outputs a HIGH digital signal when motion is detected.
Green LED
Status Indicator
Illuminates when the system is in the Standby (No motion detected) state.
Red LED
Alert Indicator
Illuminates when the system is in the Alert (Motion detected) state.
Buzzer
Audible Notification
Emits an alarm sound when the system is in the Alert state.
Export to Sheets
Video Description of Project
🔌 Hardware Connection (Wiring)
The components are connected to the Arduino Uno as follows (pin numbers are illustrative and can be modified in the code):
PIR Sensor:
VCC → Arduino 5V
GND → Arduino GND
OUT → Arduino Digital Pin 7 (Input)
Green LED (Standby):
Anode (Longer Leg) → Arduino Digital Pin 9 (via a 220Ω resistor)
Cathode (Shorter Leg) → Arduino GND
Red LED (Alert):
Anode (Longer Leg) → Arduino Digital Pin 8 (via a 220Ω resistor)
Cathode (Shorter Leg) → Arduino GND
Buzzer:
Positive (+) Pin → Arduino Digital Pin 10 (Output)
Negative (-) Pin → Arduino GND
Intruder Detection System using PIR and Arduino Part 1
Note: A current-limiting resistor (typically 220Ω) is crucial for both LEDs to prevent them from burning out.
💻 System Logic (Arduino Code Concept)
The Arduino code uses the digital input from the PIR sensor to decide the system’s state:
Initialization (setup()):
Configure PIR sensor pin (e.g., D7) as an INPUT.
Configure LED and Buzzer pins (e.g., D8, D9, D10) as OUTPUTs.
Set the initial state to Standby (Green LED ON, Red LED and Buzzer OFF).
Continuous Monitoring (loop()):
The Arduino constantly reads the digital state of the PIR sensor pin.
If motion is detected (PIR output is HIGH):
Transition to Alert state.
Turn the Green LED OFF.
Turn the Red LED ON.
Activate the Buzzer (use tone() for a continuous or pulsed alarm).
If no motion is detected (PIR output is LOW):
Transition to Standby state.
Turn the Green LED ON.
Turn the Red LED OFF.
Deactivate the Buzzer (use noTone()).
🛡️ Conclusion: Enhanced Security
This simple circuit provides an excellent introduction to building security systems. By leveraging the Arduino’s programmability, the system offers instantaneous visual and audible feedback upon detecting an intruder. The green LED reassures the user that the system is armed and monitoring, while the red LED and buzzer clearly communicate an active alert, serving both as a warning to the user and a deterrent to the intruder.
For more information on the hardware setup and code, you can check out this video: DIY HOMEMADE PIR ALARM SYSTEM with Arduino. This video describes a similar project and can help with the wiring and coding aspects of building your own PIR alarm system.
Project Code
#include <Wire.h>#include <LiquidCrystal_I2C.h>// LCD setup (address 0x27 or 0x3F depending on module)// If it doesn't work, change the addressLiquidCrystal_I2Clcd(0x27, 16, 2);// Pinsconstint pirPin = 11; // PIR sensor pinconstint buzzerPin = 2; // Buzzer pinconstint ledDetect1 = 3; // First LED for motion detectedconstint ledDetect2 = 4; // Second LED for motion detectedconstint ledIdle1 = 5; // First LED for no motionconstint ledIdle2 = 6; // Second LED for no motionintval = 0; // Value read from PIRvoidsetup() {pinMode(pirPin, INPUT);pinMode(buzzerPin, OUTPUT);pinMode(ledDetect1, OUTPUT);pinMode(ledDetect2, OUTPUT);pinMode(ledIdle1, OUTPUT);pinMode(ledIdle2, OUTPUT);digitalWrite(buzzerPin, LOW);digitalWrite(ledDetect1, LOW);digitalWrite(ledDetect2, LOW);digitalWrite(ledIdle1, LOW);digitalWrite(ledIdle2, LOW);Serial.begin(9600);// Initialize LCDlcd.init();lcd.backlight();lcd.setCursor(0, 0);lcd.print(" PIR Sensor");lcd.setCursor(0, 1);lcd.print(" Ready...");delay(2000);lcd.clear();}voidloop() {val = digitalRead(pirPin);if (val == HIGH) {// Motion detectedSerial.println("Motion detected!");lcd.clear();lcd.setCursor(0, 0);lcd.print(" Motion Detected!");lcd.setCursor(0, 1);lcd.print(" ALERT!");// Blink motion LEDs and buzzerdigitalWrite(ledDetect1, HIGH);digitalWrite(ledDetect2, HIGH);digitalWrite(buzzerPin, HIGH);delay(200);digitalWrite(ledDetect1, LOW);digitalWrite(ledDetect2, LOW);digitalWrite(buzzerPin, LOW);delay(200);// Turn off idle LEDsdigitalWrite(ledIdle1, LOW);digitalWrite(ledIdle2, LOW); } else {// No motionSerial.println("No motion...");lcd.clear();lcd.setCursor(0, 0);lcd.print(" No Motion...");lcd.setCursor(0, 1);lcd.print(" Safe :)");// Turn off motion LEDs and buzzerdigitalWrite(ledDetect1, LOW);digitalWrite(ledDetect2, LOW);digitalWrite(buzzerPin, LOW);// Turn on idle LEDsdigitalWrite(ledIdle1, HIGH);digitalWrite(ledIdle2, HIGH);delay(500); }}