Buzzer Alarm for Unauthorized Entry with Arduino: A Beginner’s Guide to Security Systems

MechatronicsLAB
4 min readNov 2, 2024

--

Objective
The objective of this Buzzer Alarm for Unauthorized Entry with Arduino project is to help beginners create a simple alarm system that detects unauthorized entry using a PIR motion sensor. This project introduces motion detection, Arduino programming, and alarm systems.

Project Goal for Buzzer Alarm for Unauthorized Entry with Arduino

  • Learn to interface a PIR motion sensor with Arduino.
  • Understand how to detect motion and trigger a buzzer alarm.
  • Build a basic security alarm system to detect unauthorized entry.

Requirement Components for Buzzer Alarm for Unauthorized Entry with Arduino

Here is the list of components needed to build the Buzzer Alarm for Unauthorized Entry with Arduino:

  1. Arduino Uno — Buy on Amazon
  2. PIR Motion Sensor — Buy on Amazon
  3. Buzzer — Buy on Amazon
  4. LED — Buy on Amazon
  5. Resistor (220 Ohm) — Buy on Amazon
  6. Breadboard — Buy on Amazon
  7. Jumper Wires — Buy on Amazon
  8. USB Cable — Buy on Amazon

Sensor Basics for Buzzer Alarm for Unauthorized Entry with Arduino

What is a PIR Motion Sensor?
The PIR (Passive Infrared) motion sensor detects infrared radiation emitted by warm objects, such as humans or animals. It is commonly used in security systems to detect motion and trigger alarms.

How Does the PIR Motion Sensor Work?

  • The PIR sensor has a pyroelectric sensor that detects changes in infrared levels.
  • It outputs a digital HIGH signal when motion is detected, indicating an unauthorized entry.

Pinout of PIR Motion Sensor

  • The PIR sensor typically has three pins:
  • VCC: Connects to the 5V pin on Arduino.
  • GND: Connects to the GND pin on Arduino.
  • OUT (Signal): Connects to a digital input pin (e.g., pin 8) on Arduino.

Sensor Real-Life Applications

  • Security Systems: Detects unauthorized entry in homes, offices, and industries.
  • Automatic Lights: Turns on lights when motion is detected.
  • Home Automation: Integrates with smart home systems for motion detection.
  • Robotics: Helps robots detect nearby obstacles or humans.

Circuit Connection for Buzzer Alarm for Unauthorized Entry with Arduino

  1. Connect the Arduino Uno: Use the USB cable to connect the Arduino Uno to your computer.
  2. Connect the PIR Motion Sensor:
  • Connect the VCC of the PIR sensor to the 5V pin on Arduino.
  • Connect the GND of the PIR sensor to the GND pin on Arduino.
  • Connect the OUT (Signal) of the PIR sensor to digital pin 8 on Arduino.
  1. 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 Buzzer Alarm Works

  • The PIR motion sensor detects motion in its range and outputs a HIGH signal.
  • When motion is detected, the Arduino triggers the buzzer and LED, generating an alarm for unauthorized entry.

Safety Tips for Buzzer Alarm for Unauthorized Entry with Arduino

  • Ensure the PIR sensor is correctly aligned to detect motion effectively.
  • Use a resistor to limit the current to the LED and prevent damage.
  • Disconnect the power supply when making or modifying circuit connections.

Arduino Programming Section for Buzzer Alarm for Unauthorized Entry with Arduino

Arduino Syntax

  • digitalWrite(pin, value); — Sets a digital pin to HIGH or LOW.
  • digitalRead(pin); — Reads the digital value from a specified pin.
  • if (condition) { } — Executes code if the condition is true.

Arduino Code for Buzzer Alarm for Unauthorized Entry 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 Buzzer Alarm for Unauthorized Entry with Arduino

  1. Open the Arduino IDE on your computer.
  2. Connect the Arduino Uno using the USB cable.
  3. Select the Board: Go to ‘Tools’ > ‘Board’ > ‘Arduino Uno’.
  4. Select the Port: Go to ‘Tools’ > ‘Port’ and select the correct port.
  5. Upload the Code: Copy the code above, paste it into the IDE, and click ‘Upload’.

Check Output of Buzzer Alarm for Unauthorized Entry with Arduino

After uploading the code, move in front of the PIR sensor. When the sensor detects motion, the buzzer will sound, and the LED will light up, indicating unauthorized entry.

Code Explanation for Buzzer Alarm for Unauthorized Entry with Arduino

  • digitalRead(pirPin);: Reads the state of the PIR motion sensor (HIGH when motion is detected).
  • digitalWrite(buzzerPin, HIGH);: Activates the buzzer when motion is detected.
  • digitalWrite(ledPin, HIGH);: Turns on the LED for a visual alert when motion is detected.
  • delay(2000);: Keeps the alarm active for 2 seconds before resetting.

Troubleshooting Tips for Buzzer Alarm for Unauthorized Entry with Arduino

  • No response from the PIR sensor? Check the sensor connections and ensure it is positioned correctly.
  • Buzzer or LED not working? Verify their connections to the Arduino.
  • 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 Buzzer Alarm for Unauthorized Entry, 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 Buzzer Alarm for Unauthorized Entry with Arduino and enhance your home security projects

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

MechatronicsLAB
MechatronicsLAB

Written by MechatronicsLAB

0 Followers

Our main focus will be on Mechatronics Technology where we will work in #Industrial_Automation, #PLC, #IoT, #Raspberry_Pi, #Arduino, #Microcontroller

No responses yet

Write a response