Door Alarm Security System - LBM4

Recent Post

Saturday, 17 August 2019

Door Alarm Security System

It is a simple tutorial on how to create little a security device using an Arduino.

Here we are going to make door alarm security system using HC-Ultrasonic sensor. The used ultrasonic sensor is used as distance sensor, it will tell us the distance at which the object is placed. Using this distance value, we will turn the buzzer on or off.

Components Required:

  1. Arduino Uno
  2. Bread Board
  3. UltrasonicSensor - HC-SR04 (Generic)
  4. Buzzer
  5. Connecting Wire


The connections for the ultrasonic sensor with Arduino are as follows.

Ultrasonic Sensor
5 v pin
Trig Pin
Echo pin
Pin 3

Connect positive pinon buzzer with pin 10 on Arduino and Buzzer negative pin with GND pin on Arduino.

Working Mechanism:

The ultrasonic sensor emits an ultrasonic wave from the trigger which comes back after hitting the object and it is received by the travelled in microsecond. To send an ultrasonic wave from the trigger, we will have to set trigger for 10 micro-second. It will send an 8 cycles sonic burst at 40 KHZ which will hit object and is then received by the echo.

Distance = v*t

Here we have value of t and we know that the speed of sound wave is 340 m/s. We have to convert speed of sound into cm/ micro-second to calculate distance. The speed of sound in cm/ micro-second is 0.034 cm/ micro-second. Then,

 S= 0.034*t

We require only the distance it take to hit the object so,


We will get the distance value using equation above and after that we will set a value which help us to make the buzzer high or low.


int trigger_pin = 2;

int echo_pin = 3;

int buzzer_pin = 10; 

int time;

int distance; 

void setup ( ) {

        Serial.begin (9600); 

        pinMode (trigger_pin, OUTPUT); 

        pinMode (echo_pin, INPUT);

        pinMode (buzzer_pin, OUTPUT);


void loop ( ) {

    digitalWrite (trigger_pin, HIGH);

    delayMicroseconds (10);

    digitalWrite (trigger_pin, LOW);

    time = pulseIn (echo_pin, HIGH);

    distance = (time * 0.034) / 2;

  if (distance <= 10) 


        Serial.println (" Door Open ");

        Serial.print (" Distance= ");              

        Serial.println (distance);        

        digitalWrite (buzzer_pin, HIGH);

        delay (500);


  else {

        Serial.println (" Door closed ");

        Serial.print (" Distance= ");              

        Serial.println (distance);        

        digitalWrite (buzzer_pin, LOW);

        delay (500);        

( If you have any confusion feel free to discuss in comment)


  1. I went to this website, and I believe that you have a plenty of excellent information, I have saved your site to my bookmarks. Complete Alarm Systems

  2. I got too much interesting stuff on your blog. I guess I am not the only one having all the enjoyment here! Keep up the good work. Complete Alarm Systems

  3. i really like this article please keep it up. fabbro viareggio

  4. i never know the use of adobe shadow until i saw this post. thank you for this! this is very helpful. ip cameras

  5. I think this is a really good article. You make this information interesting and engaging. You give readers a lot to think about and I appreciate that kind of writing. Security Screen Windows

  6. Most homes have picked to introduce security systems now. The expanded interest for security systems among house proprietors of today are a result of the different advantages they offer. cctv camera installation near me

  7. Gated access control When your website or blog goes live for the first time, it is exciting. That is until you realize no one but you and your.

  8. Gated access control When your website or blog goes live for the first time, it is exciting. That is until you realize no one but you and your.

  9. Great post, and great website. Thanks for the information! k7 total security activation key

  10. Think about the exemplary "Form a superior mousetrap" model instructed in many business colleges. Access Control System

  11. Without fail, your writing style is top professional; even your website also looks amazing thank you for posting. security alarm price

  12. I truly appreciate this post. Really looking forward to read more. alarm system installation

  13. You know your projects stand out of the herd. There is something special about them. It seems to me all of them are really brilliant! singapore security alarm

  14. It might come as an amazement to hear that numerous entryways can be created as sliding entryways. This implies that regardless of whether you see an entryway you like and it's anything but a sliding entryway, you can demand the style be made into a sliding entryway by the maker.telescopic auto sliding door