Have you ever wonder what type of sensor that you can use to sense for obstacle ? Well, in this post, I am going to explain a brief detail about using a HC-SR04 Ultrasonic Sensor for sensing obstacle.
The HC-SR04 sensor is using the sonar to determine the distance to an object like what you know about bats or dolphin. It comes complete with ultrasonic transmitter and recevier module.
Some features of the HC-SR04 ultrasonic sensor :
- Power supply : +5V DC
- Working current : 15mA
- Measuring angle : 30 degree
- Ranging distance : 2cm - 400cm
Datesheet HC-SR04
A very good video preview on ultrasonic sensor !
Let's get started !
Hardware :
- HC-SR04 x 1
- LCD x 1
- Arduino x 1
- Buzzer x 1
- Few jumper wires
- Arduino IDE
Connect your HC-SR04 as shown below :
Connect a buzzer to Pin 7 of arduino UNO.
Software :
I found a pretty easy to use arduino library for this. You may download it here :
Ping Library
You may want to view the guide below on how to use this library in arduino
Ping Library Guide
I have uploaded below code to my arduino
Download Code
A simple demo on my project using HC-SR04:
Feel free to comment and ask if you have any doubt. Would try my best to answer and help :)
Thanks
i used same Ultrasonic Sensor few days back.
ReplyDeleteit's amazing and is very accurate too.
Yup, I have tested it. Quite accurate with the readings given :)
DeleteHaHahaha, this is because the sonar.ping_cm will give you the value like 20 if 20cm la.
ReplyDeleteSo I just add that to increase my delay time only. If delay(20) and delay(30) seems not big difference. So I multiply it with 10 to have a slight obvious difference between the delay for different distance.
Do you get what I mean ?
Thanks :)
I also sell this type of sensor Only RM20/pcs..
ReplyDeletewww.daxtronics.com.my
That is cheap ! Maybe you can attach the link here so that it will direct the reader to that particular item ?
DeleteThanks :)
Thanks :D
Deletehttp://www.daxtronics.com.my/index.php?route=product/product&product_id=135