et object/distance detection in your project using the low-cost HC-SR04 Ultrasonic Distance Module from Elegoo. Using the same principle as bats (Echo location), this module uses Trigger and Echo pin to send a signal and listen for it to be 'bounced back'. With a few lines of code you'll be detecting objects for your project. This module is the perfect option for detecting objects between 2cm-500cm in front of your project.
- Range - This module can detect objects between 2cm and 500cm in front of itself with an angle of 15 degrees either side.
- Accuracy - The readings of the module can be broken down into 0.3cm increments, which is plenty for most robotics projects
- Mounting - Used by many makers, in many projects, the 4 holes on the circuit board make for easy mounting into your project
- Software - As a favorite distance sensor, there are plenty of libraries and examples available to use with Arduino, Micro:bit, Raspberry Pi and other maker platforms.
- Distance calculation - Once it's wired up, you'll use the formula: distance = (traveltime/2) x speed of sound for a measurement in centimeters
HOW TO USE THIS ULTRASONIC DISTANCE SENSOR
As this module is a 5V sensor, you can use it with almost any of the popular maker platforms (Arduino, micro:bit, etc). You'll simply need to wire the device up to your board and configure the trigger and echo pins as Output/Input pins respectively. Once you've got it configured correctly, use your code to take the Input reading from the Echo pin and plug it into the distance formula: distance = (traveltime/2) x speed of sound to get a distance reading.
It's really that easy. There's even a library for Arduino, NewPing, that makes the process even easier for you. We've written a pretty comprehensive guide on how you can use this module in your projects. It's guaranteed to get you up to speed as fast as possible.