Burglar Alarm System With Arduino

Kasunjayanga Kj
2 min readSep 28, 2021

In modern days Robbery has become a big issue, especially in urban areas. well of course you could purchase an alarm system unless it comes with a huge price and compact maintenance. That’s where the Arduino microcontroller, which operates around 16 Mhz processing power and is also very cheap comes to your help.

Now, this article is how I built the burglar alarm system and its implications. this alarm system is very cheap and you don’t have to spend huge money on buying an alarm system, plus there will be no compact maintenance. it’s your project. I mean you can change anything you can implement new things. That's the power of Arduino.

Here’s the list of items needed,

>Arduino Uno

>HC-SR04 Ultrasonic Sensor

>A buzzer

>A 100ohm resistor

>Jumper Wires

>9v battery/power supply

This is the basic circuit diagram

Though the ultrasonic sensor HC-SR04 is capable of working at a distance of 400 cm, it’s better if u can keep that around 100cm. so once you have completed building the circuit you can start to upload the code. once the code is uploaded you can connect the power source or 9v battery to power the Uno board .and set up the instrument so that the ultrasonic sensor projects at a door or passageway such that it could detect any movement. the buzzer will activate if there’s any difference occurred with the distance stored in the program(you can change the distance by changing integer variable distancetothedoor)

watch the demonstration video here https://youtu.be/53cWBqa0MWo

#include <NewPing.h>// this library will do all the work in calculating distance

//Tig 12, eco 11
NewPing sonar(12, 11,300);

void setup() {
Serial.begin(9600);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
}

void loop() {
delay (200);
Serial.print (“distance: “);
Serial.print (sonar.ping_cm());
Serial.println (“cm”);
int distancetodoor=30;
if(sonar.ping_cm() != distancetodoor){

digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
delay(1000);

}
else
{digitalWrite(7,LOW);}
}
int distance(){
delay (2000);
Serial.println(sonar.ping_cm());
return sonar.ping_cm();
}

--

--