Hello There Fellow Electronic Enthusiasts and Hobbyists! We integrate different sensors with our Arduino Board for different applications. Here is another Sensor Tutorial where we will integrate Arduino Ultrasonic Sensor Module or HC-SR01 Module on our Arduino Board.
So let’s get started!
Watch the Video
Gather the Requirements.
1. Arduino Uno (any Arduino Board).
https://in.gearbest.com/development-boards/pp_6297…
2. Ultra Sonic Sensor Module.
https://in.gearbest.com/development-boards/pp_1989…
3. Connecting Wires.
Understanding the Working of Ultra Sonic Module.
So this HC-SR04 Module consists of 5 major parts namely.
- Transmitter
- Receiver
- Microcontroller unit
- Transmitting Amplifier and also
- Receiving amplifier
however We will use Speed Time and Distance relation Formula which is:
Time = Distance /Speed
We will modify this formula according to our conditions and also use case.
We have, Ultrasonic Sound wave of 40 K Hertz.
The speed for us here is Speed of Sound, and which is 340 m/s.
We need our calculations in cm, so we have Speed = 0.034 cm/us ( Cm per Micro Second).
now the distance becomes
Distance = 0.034 * Time / 2
(here we want time of travel from point A to B, but the wave is going from A to B and returns to A so the time is divided by 2)/
So we will get the time from our Module via Echo pin from our Module.
Connections.
Connections Part is Very Simple(arduino ultrasonic sensor)
Vcc to 5V.
Ground to Ground of Arduino.
Trig to Digital Pin 9.
Echo to Digital Pin 10.
Code.
We will first Declare Constants and variables
Next, In Void setup, we will define Pin modes of Trigger and Echo pins and then initializes the Serial Com
Then, we will clear the Trigger Pin with a 2 microsecond Low pulse, and then we will trigger the Pin 9 using a 10 Microsecond high Pulse.
This when received on Micro-Controller unit of module, it transmits a train of 8 pulse cycles.
So now the data received on receiver will be stored in variable called as Duration, and finally we will Implement our Formula in a Variable called Distance and at the end of this Code, we will Display “ Distance “ in Serial Com port using ‘serial.println’ command.
And once the code is done, simply upload it to your Arduino board and we are all set to receive distance from our sensor module!
Conclusion.
So you can use this project and make your own electronic scale or something more complicated like some automation application!
Whatever you make! Do share it with me on “I made it ” tab of this article