Header Ads

Burglar Alarm System Using Ultrasonic sensor + LED + Arduino

 What is the Ultrasonic sensor Arduino System?👀

Ultrasonic ranging module HC - SR04 provides 2cm - 400cm non-contact measurement function, the ranging accuracy can reach to 3mm. The modules includes ultrasonic transmitters, receiver and control circuit.

This is a simple example of using the ultrasonic sensor (HC-SR04) in Arduino where we will turn on a led with the variation of distance and print the distance from an object to the serial monitor.

Necessary Components For this Task👇

01.Arduino Uno

02.UltraSonic Sensor(HC-SR04)

03.Resistors

04.Jumper Wires

05.LED




How to connect the Components👇


The connection of the components is very easy it is only necessary to follow the above pictures.😊

Now You Can Write Your Code✌😇


#define trigPin 13

#define echoPin 12

#define led 11

void setup()

{ Serial.begin (9600);

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

pinMode(led, OUTPUT);

}

void loop()

{ long duration, distance;

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance = (duration/2) / 29.1;

if (distance < 10)

{ digitalWrite(led,HIGH);

}

else {

digitalWrite(led,LOW);

}

Serial.print(distance);

Serial.println(" cm");

delay(500);

}

**(Run Your Code & Look The Burglar Alarm System)😋😉


This Video For Easy to Create your Alarm System👇👇




No comments

Powered by Blogger.