Security Alarm using Arduino and PIR Sensor
To create a security alarm system that detects unauthorized access or intrusion and alerts the user through audible and/or visual alarms.
1. Arduino board (such as Arduino Uno)
3. Buzzer or piezo speaker
4. LED (optional for visual indication)
Connect the PIR motion sensor module to the Arduino. The sensor typically has three pins: VCC, GND, and SIGNAL. Connect VCC to 5V, GND to GND, and SIGNAL to a digital input pin (e.g., pin 2) on the Arduino.
Connect the buzzer or piezo speaker to the Arduino. Connect one terminal of the buzzer to a digital output pin (e.g., pin 3) on the Arduino and the other terminal to GND.
Optionally, connect an LED to a digital output pin (e.g., pin 4) on the Arduino for visual indication.
#define PIR_PIN 2 // Digital pin connected to PIR sensor
#define BUZZER_PIN 3 // Digital pin connected to buzzer
#define LED_PIN 4 // Digital pin connected to LED (optional)
void setup() {
pinMode(PIR_PIN, INPUT);
pinMode(BUZZER_PIN, OUTPUT);
pinMode(LED_PIN, OUTPUT);
Serial.begin(9600);
Serial.println("Security Alarm System - Ready");
}
void loop() {
int motionDetected = digitalRead(PIR_PIN);
if (motionDetected == HIGH) {
digitalWrite(BUZZER_PIN, HIGH); // Activate the buzzer
digitalWrite(LED_PIN, HIGH); // Turn on the LED (optional)
Serial.println("Intruder Detected - Alarm Activated!");
delay(5000); // Alarm duration (adjust as needed)
digitalWrite(BUZZER_PIN, LOW); // Deactivate the buzzer
digitalWrite(LED_PIN, LOW); // Turn off the LED (optional)
}
}
The completed security alarm system provides effective protection against unauthorized access or intrusion, alerting users to potential security threats through audible and/or visual alarms. With its customizable features and robust functionality, the system enhances the security and peace of mind of users in various environments.
Comments
Post a Comment