Arduino Ultrasonic Sensor Door Alarm

Introduction: Arduino Ultrasonic Sensor Door Alarm

This is a simple Arduino ultrasonic sensor hcsro4 door alarm.
This mechanism is very simple and easy.
You can do it with only some of the parts in the Arduino Uno set which I have bought from Amazon.

Supplies:

These are the parts we are gonna use in this set of the project: :
1 : HC-SRO4
1 : simple buzzer
1: simple and small breadboard
1 : a - b usb cable
6 : jumper wires
1 : generic Arduino Uno board

Softwares ;
Arduino IDE

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Connections

Vcc- 5v
Trig Arduino pin 2
Echo Arduino pin 3
Gnd to gnd

Step 2: Source Code

int tiger=2;
int echo=3;
int a=12;
int Duration,Distance;
void setup()
{
pinMode(tiger,OUTPUT);
pinMode(echo,INPUT);
Serial.begin(9600);
pinMode(a,OUTPUT);
}
void loop()
{
digitalWrite(tiger,HIGH);
delayMicroseconds(1000);
digitalWrite(tiger,LOW);
Duration=pulseIn(echo,HIGH);
Distance=(Duration/2)/29.1;
Serial.print("cm=");
Serial.print(Distance);
delay(500);
if (Distance<50)
{
digitalWrite(a,HIGH);
delay(1000);
}
else
digitalWrite(a,LOW);
delay(200);

}

Step 3: The Source Code !!

int tiger=2;
int echo=3;
int a=12;
int Duration,Distance;
void setup()
{
pinMode(tiger,OUTPUT);
pinMode(echo,INPUT);
Serial.begin(9600);
pinMode(a,OUTPUT);
}
void loop()
{
digitalWrite(tiger,HIGH);
delayMicroseconds(1000);
digitalWrite(tiger,LOW);
Duration=pulseIn(echo,HIGH);
Distance=(Duration/2)/29.1;
Serial.print("cm=");
Serial.print(Distance);
delay(500);
if (Distance<50)
{
digitalWrite(a,HIGH);
delay(1000);
}
else
digitalWrite(a,LOW);
delay(200);

}

Be the First to Share

    Recommendations

    • Trash to Treasure Contest

      Trash to Treasure Contest
    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest

    3 Discussions

    0
    seamster
    seamster

    2 months ago

    Thanks for sharing! : )

    0
    Yashvanth kumar
    Yashvanth kumar

    Reply 2 months ago

    Did you make the project!!!
    if you did.
    please send the photo by clicking I made it button below please