Simple Motion Sensor Alarm

Simple Motion Sensor Alarm

This project guides you to build a basic motion sensor alarm that detects movement using a PIR sensor. When motion is detected, a buzzer sounds loudly and a red LED flashes, providing clear alerts. It is perfect for beginners and requires only common electronic components.

Beginner 1 hour $15
Step-by-Step Instructions
1. Connect the PIR sensor's VCC pin to Arduino 5V and GND to Arduino GND.
2. Connect the PIR sensor's output pin to Arduino digital pin 2.
3. Connect the LED's long leg (anode) to Arduino digital pin 13 through a 220-ohm resistor; connect the short leg (cathode) to GND.
4. Connect the buzzer's positive pin to Arduino digital pin 8 and negative pin to GND.
5. Open Arduino IDE on your computer and write/upload the following code:
```
int pirPin = 2;
int ledPin = 13;
int buzzerPin = 8;
void setup() {
pinMode(pirPin, INPUT);
pinMode(ledPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
int motion = digitalRead(pirPin);
if (motion == HIGH) {
digitalWrite(ledPin, HIGH);
tone(buzzerPin, 1000); // 1kHz sound
delay(200);
digitalWrite(ledPin, LOW);
noTone(buzzerPin);
delay(200);
} else {
digitalWrite(ledPin, LOW);
noTone(buzzerPin);
}
}
```
6. Upload the code to the Arduino.
7. Power the Arduino via USB or external supply.
8. Test by moving in front of the PIR sensor; the LED should flash and buzzer sound when motion is detected.
Materials
1 x PIR motion sensor module
1 x Arduino Uno or similar microcontroller
1 x Red LED
1 x 220-ohm resistor
1 x Piezo buzzer (active)
Jumper wires
Breadboard
USB cable for Arduino
Computer with Arduino IDE installed
More Projects You Might Like
Handmade Soy Candles
Create a Magical Miniature Garden Terrarium
Automated Plant Watering System
Boho Cancer Zodiac Sign Painting
Gear-shaped Aluminum Sheet Carving
Glowing Ghost Jars
Spooky Pumpkin Planters
Spooky Spiderweb Living Room
Spooky Spider Web Garden Decor
Tiny Dragons Socks Knitting Pattern
Homemade Bath Bombs and Soaps for a Spa-like Experience
Build a Birdhouse
Intricate Paper Quilling Art
Succulent Terrarium with Decorative Stones