Introduction: Arduino Ultrasonic Sensor Door Alarm
This is a very simple ultrasonic sensor door alarm for beginners.
this needs just a few stuff you need to gather from any online shoppers you need.
I bought it from Amazon and I recommend to buy in amazon
this needs just a few stuff you need to gather from any online shoppers you need.
I bought it from Amazon and I recommend to buy in amazon
Supplies
One ultrasonic sensor
One Simple buzzer
One Arduino Uno generic board
One a to b usb cable
Some jumper wires
One generic breadboard
Softwares are:::-ARDUINO IDE
One Simple buzzer
One Arduino Uno generic board
One a to b usb cable
Some jumper wires
One generic breadboard
Softwares are:::-ARDUINO IDE
Step 1: The Connections Are :::- πππ
Vcc- 5v
Trig- Arduino pin 2
Echo- Arduino pin 3
Gnd- gnd
Buzzer connections ::-
Plus to 5v
Minus to Arduino pin 12
Trig- Arduino pin 2
Echo- Arduino pin 3
Gnd- gnd
Buzzer connections ::-
Plus to 5v
Minus to Arduino pin 12
Step 2: Just Programming Slightly πππ€
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);
}
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: How It Works
It is just a simple mechanism.
Just if an object comes to a distance the buzzer buzzes.
Just play with itπππ€π€π€πππ€π€
Just if an object comes to a distance the buzzer buzzes.
Just play with itπππ€π€π€πππ€π€