DISTANCE MEASUREMENT USING ULTRASONIC SENSOR WITH ARDUINO
In this article i will explain about Ultrasonic HC-SR04 Sensor.
What is ultrasonic sensor? and how does ultrasonic sensor working and will tell about it,s feature.I will show you schematics diagram and wiring to Arduino with some simple example. You can follow this article for your project.
I am already 3 articles published based on Arduino projects. If you want to make projects. so you go read articles and make it.
ULTRASONIC SENSOR :-
There are Three sections of HC-SR04 ultrasonic sensor:-
1.Transmitter
2.Receiver
3.Circuit of HC-SR04
FEATURE :-
FEATURE :-
There are some follow features of HC-SR04 Ultrasonic Module.
- Power supply 5v . .
- During working current 15 mA.
- Distance range approx 2 cm to 400 cm.
- Resolution 0.3 cm.
- Measuring angle 30 degree.
- Trigger input pulse with 10 us.
HOW DOES IT WORK?
We know that ultrasonic sensor uses to determine the distance to an object. Here HC-SR04 sensor have three parts Transmitter,Receiver and Circuit part of HC-SR04 module.
Transmitter transmits the ultrasound wave signal with high frequency from Trigger pin.
When the ultrasound wave detected any solid object ,then it is reflected and the receiver receive the reflected sound from the echo pin. And calculate the time between transmission signal and reception (Reflected) transmission to an object.I have seen formula below .
Distance = ( Velocity * Time )/2
PIN OUT:-
VCC - 5v
Trigger - Trigger(Input Pin)
Echo - Echo(Output Pin)
GND - GND
COMPONENT REQUIRED
- Arduino Uno with cable
- HC-SR04 Ultrasonic Sensor
- Bread board
- Buzzer
- 9v Battery
- Jumper wire some Male and Female pins
HC-SR04 SENSOR INTERFACE TO ARDUINO
This sensor is very popular with Arduino and here a lot of projects available in the internet with Arduino. I will tell you the sensor connection with Arduino board and with see code of HC_SR04 Ultrasonic sensor module and reads the distance of an object and display on the serial monitor.
The goal of our project is to understand. How ultrasonic sensors work and how we can use this sensor in our project.
HC-SR04 - Arduino Uno
VCC - 5V
GND - GND
Echo - Pin 3
Trig - Pin 4
Buzzer - Arduino Uno
- Terminal - GND
+ Terminal - Pin 2
CODE
int buzzer = 2;
int echoPin = 3;
int trigPin = 4;
long duration,cm,inch;
void setup()
{
Serial.begin(9600);
pinMode(trigPin,OUTPUT);
pinMode(echoPin,INPUT);
pinMode(buzzer,OUTPUT);
}
void loop()
{
digitalWrite(trigPin,LOW);
delayMicroseconds(2);
digitalWrite(trigPin,HIGH);
delayMicroseconds(10);
digitalWrite(trigPin,LOW);
pinMode(echoPin,INPUT);
duration = pulseIn(echoPin,HIGH);
cm = (duration / 2) / 29.1;
inch = (duration / 2 ) /74;
Serial.print(" CM = " );
Serial.print( cm );
Serial.print( " " );
Serial.print( " INCH = " );
Serial.println( inch );
if(cm > 0 & cm < 20)
{
digitalWrite(buzzer,HIGH);
}
else
{
digitalWrite(buzzer,LOW);
}
delay(500);
}
Serial Monitor
0 Comments