Intruder Alarm System with Arduino: A Beginner’s Guide to Home Security Projects
Objective
The objective of this Intruder Alarm System with Arduino project is to help beginners create a simple alarm system that detects movement using a PIR motion sensor. This project introduces basic security systems, Arduino programming, and sensor integration.
Project Goal for Intruder Alarm System with Arduino
- Learn to interface a PIR motion sensor with Arduino.
- Understand how to detect motion and trigger an alarm.
- Build a basic security system that detects intruders and activates a buzzer or LED alarm.
Requirement Components for Intruder Alarm System with Arduino
Here is the list of components needed to build the Intruder Alarm System with Arduino:
- Arduino Uno — Buy on Amazon
- PIR Motion Sensor — Buy on Amazon
- Buzzer — Buy on Amazon
- LED — Buy on Amazon
- Resistor (220 Ohm) — Buy on Amazon
- Breadboard — Buy on Amazon
- Jumper Wires — Buy on Amazon
- USB Cable — Buy on Amazon
Sensor Basics for Intruder Alarm System with Arduino
What is a PIR Motion Sensor?
The PIR (Passive Infrared) Motion Sensor detects infrared radiation emitted by warm objects, such as humans and animals. It is widely used in security systems to detect motion within a given range.
How Does the PIR Motion Sensor Work?
- The PIR sensor detects changes in infrared radiation within its field of view.
- When motion is detected, the sensor outputs a digital HIGH signal, indicating the presence of an intruder.
- It has two potentiometers for adjusting sensitivity and delay time.
Pinout of PIR Motion Sensor
- The PIR motion sensor has three pins:
- VCC: Connects to the 5V pin on Arduino.
- OUT: Connects to a digital input pin (e.g., pin 8) on Arduino.
- GND: Connects to the GND pin on Arduino.
Sensor Real-Life Applications
- Home Security Systems: Detects unauthorized entry and triggers an alarm.
- Automatic Lighting Systems: Activates lights when motion is detected.
- Smart Doorbells: Senses movement and alerts users of visitors.
- Automatic Gates: Opens gates upon detecting approaching vehicles or individuals.
Circuit Connection for Intruder Alarm System with Arduino
- Connect the Arduino Uno: Use the USB cable to connect the Arduino Uno to your computer.
- Connect the PIR Motion Sensor:
- Connect the VCC of the PIR sensor to the 5V pin on Arduino.
- Connect the OUT of the PIR sensor to digital pin 8 on Arduino.
- Connect the GND of the PIR sensor to the GND pin on Arduino.
- Connect the Buzzer and LED:
- Connect the positive leg of the buzzer to digital pin 9 on Arduino.
- Connect the negative leg of the buzzer to the GND pin on Arduino.
- Connect the positive leg of the LED to digital pin 10 through a 220 Ohm resistor.
- Connect the negative leg of the LED to the GND pin on Arduino.
Circuit Connection Analysis: How the Intruder Alarm System Works
- The PIR motion sensor detects motion by sensing changes in infrared radiation. When motion is detected, it sends a HIGH signal to the Arduino.
- The Arduino processes this signal and triggers the connected buzzer and LED, indicating an intrusion.
- The buzzer and LED act as the alarm, providing audio and visual alerts when an intruder is detected.
Safety Tips for Intruder Alarm System with Arduino
- Disconnect the power supply when connecting or modifying the circuit.
- Position the PIR sensor properly to avoid false triggers (e.g., avoid direct sunlight or heat sources).
- Secure all connections to ensure proper functioning.
Arduino Programming Section for Intruder Alarm System with Arduino
Arduino Syntax
- pinMode(pin, mode); — Sets a pin as INPUT or OUTPUT.
- digitalRead(pin); — Reads the digital value from a specified pin.
- digitalWrite(pin, value); — Sets a digital pin to HIGH or LOW.
- delay(milliseconds); — Pauses the program for a specified time.
Arduino Code for Intruder Alarm System with Arduino
const int pirPin = 8; // PIR sensor connected to digital pin 8
const int buzzerPin = 9; // Buzzer connected to digital pin 9
const int ledPin = 10; // LED connected to digital pin 10
void setup() {
pinMode(pirPin, INPUT); // Set PIR sensor pin as input
pinMode(buzzerPin, OUTPUT); // Set buzzer pin as output
pinMode(ledPin, OUTPUT); // Set LED pin as output
}
void loop() {
int pirState = digitalRead(pirPin); // Read PIR sensor state
if (pirState == HIGH) { // If motion is detected
digitalWrite(buzzerPin, HIGH); // Activate buzzer
digitalWrite(ledPin, HIGH); // Turn on LED
delay(2000); // Keep alarm on for 2 seconds
} else {
digitalWrite(buzzerPin, LOW); // Deactivate buzzer
digitalWrite(ledPin, LOW); // Turn off LED
}
delay(100); // Small delay for stability
}
Steps to Upload Code for Intruder Alarm System with Arduino
- Open the Arduino IDE on your computer.
- Connect the Arduino Uno using the USB cable.
- Select the Board: Go to ‘Tools’ > ‘Board’ > ‘Arduino Uno’.
- Select the Port: Go to ‘Tools’ > ‘Port’ and select the correct port.
- Upload the Code: Copy the code above, paste it into the IDE, and click ‘Upload’.
Check Output of Intruder Alarm System with Arduino
After uploading the code, place the PIR sensor in a location where it can detect motion. When motion is detected, the buzzer will sound, and the LED will light up for 2 seconds, indicating an intruder.
Code Explanation for Intruder Alarm System with Arduino
- digitalRead(pirPin);: Reads the state of the PIR sensor (HIGH when motion is detected).
- digitalWrite(buzzerPin, HIGH);: Activates the buzzer when motion is detected.
- digitalWrite(ledPin, HIGH);: Turns on the LED to provide a visual alert.
- delay(2000);: Keeps the alarm active for 2 seconds.
Troubleshooting Tips for Intruder Alarm System with Arduino
- No response from the sensor? Check the PIR sensor connections and ensure it has been powered for at least 30 seconds to warm up.
- Buzzer or LED not working? Verify their connections to the Arduino and ensure the correct digital pins are used.
- Code not uploading? Confirm the correct board and port settings in the Arduino IDE.
Suggestion for Beginners
Book Recommendation
For a comprehensive guide on Arduino programming, I recommend Arduino Programming for Absolute Beginners. This book covers projects like the Intruder Alarm System, offering clear instructions and practical examples.
Free Tutorials
For more tutorials on Arduino, ESP8266, ESP32, and Raspberry Pi projects, visit mechatronicslab.net.
Start building your own Intruder Alarm System with Arduino and enhance your home security projects!