Introduction: Distance Measurement With Ultrasonic Sensor and Arduino

Here I have shown a simple way to measure distance and detect objects using ultrasonic sonar and Arduino. I have mentioned the connection diagram and provided the coding as well. Also I made a video on the topic in DIY style and uploaded to my channel. The video link also is provided in the last step.

Thanks for all the websites where the images are downloaded from.

Please find my channel and subscribe for more DIY projects and tutorials: https://www.youtube.com/channel/UCZHxq0gM-m-sDQIjP...

Step 1: Arrange the Equipment

The Equipment you need are:

1. Arduino (I used a Uno board)

2. Ultrasonic sonar (https://www.ebay.com/p/1pcs-Ultrasonic-Module-Hc-s...

3. Jumper wires (male to female)

4. Computer to read the serial monitor

Step 2: Connection

Connect the wires of the sonar to the Arduino as follows:

Sonar Arduino

Gnd Ground

Echo Digital pin 10

Trig Digital pin 9

Vcc 5V

Provide power to the Arduino using usb cable with computer.

Step 3: Coding

Please find the coding in the following link: https://drive.google.com/file/d/1_BWU5w-HfGABOPc2A...

Attachments

Step 4: Upload and Test

Upload the code to the Arduino and open your serial monitor.

Bring an object near to the sonar and you will see the distance value in centimeters.

The demonstration you can find in the video (at the end of the video) :

Good Luck!!!