Buzzer Alarm System With Help Of Arduino

Buzzer Alarm System With Help Of Arduino © GPL3+

This project will guide you to set up an alarm system using a motion detector.

  • 55,200 views
  • 9 comments
  • 33 respects

Components and supplies

Apps and online services

About this project

This is a simple alarm system made with help of buzzer, LED and a motion detector. One can stop the buzzer by pressing the button.

Steps:

  • Connect the +5V and GND of Arduino UNO to the breadboard.
  • For LED: Connect the cathode (Shorter pin of LED) to ground and the Anode (longer pin of LED) with a 330 or 220 ohm resisitor. Connect the second pin of resistor with pin 6 of the Arduino as shows in schematics.
  • For Buzzer: Connect the Positive terminal with pin 5 of Arduino and negative terminal to GND.
  • For Button: Connect the button with a 1Kohm resistor to GND and to Positive terminal. Connect the other end with pin 12 as shown in schematics.
  • For Motion Sensor: Connect the +Vcc pin with positive, GND with with Ground terminal and Sensor pin with pin 7 of Arduino.

The setup is now ready. Now load the code in Arduino IDE and then Upload it to Arduino. Check the Serial Monitor readings. Try moving your hands in front of the sensor and the buzzer should ring.

Tip: You can fix this alarm near the door. If motion is detected,the buzzer will ring.

Code

Code for projectArduino
// Declaring Pins
const int buzzerPin = 5;
const int ledPin = 6;
const int motionPin = 7;
const int buttonPin = 12;

// Setting Buzzer mode to False
boolean buzzer_mode = false;

// For LED
int ledState = LOW;
long previousMillis = 0; 
long interval = 100;  // Interval at which LED blinks

void setup()
{
  //The Following are our output
  pinMode(ledPin,OUTPUT);
  pinMode(buzzerPin,OUTPUT);

  //Button is our Input
  pinMode(buttonPin, INPUT);
  
  // Wait before starting the alarm
  delay(5000);
}

void loop()
{
  // To chech whether the motion is detected or not
  if (digitalRead(motionPin)) {
    buzzer_mode = true; 
  }

  // If alarm mode is on,blink our LED
  if (buzzer_mode){
    unsigned long currentMillis = millis();
    if(currentMillis - previousMillis > interval) {
      previousMillis = currentMillis;   
      if (ledState == LOW)
        ledState = HIGH;
      else
        ledState = LOW;
    // Switch the LED
    digitalWrite(ledPin, ledState);
    }
    tone(buzzerPin,1000);
  }

  // If alarm is off
  if (buzzer_mode == false) {
  
    // No tone & LED off
    noTone(buzzerPin);  
    digitalWrite(ledPin, LOW);
  }

  // If our button is pressed Switch off ringing and Setup
  int button_state = digitalRead(buttonPin);
  if (button_state) {buzzer_mode = false;}
}

Schematics

Schematic for the project
Schematic

Comments

Similar projects you might like

Android App-Based Home Automation System Using IOT

Project tutorial by Team Autoshack

  • 24,825 views
  • 17 comments
  • 75 respects

Security System And Access Control With Arduino And RFID

Project tutorial by Sarath P

  • 7,251 views
  • 0 comments
  • 18 respects

Plant watering alarm system with arduino

Project tutorial by Giannis Arvanitakis

  • 3,397 views
  • 1 comment
  • 5 respects

Distance Alarm System

Project tutorial by Darwin Dela Cruz

  • 2,995 views
  • 3 comments
  • 14 respects

Ultrasonic Security System

Project tutorial by Ivan

  • 17,281 views
  • 18 comments
  • 50 respects

Morse Code Communication Using Arduino

Project tutorial by Jalal_Mansoori

  • 2,701 views
  • 7 comments
  • 19 respects
Add projectSign up / Login