Ultrasonic range finders measure distance by emitting a pulse of ultrasonic sound that travels through the air until it hits an object. When that pulse of sound hits an object, it’s reflected off the object and travels back to the ultrasonic range finder. The ultrasonic range finder measures how long it takes the sound pulse to travel in its round trip journey from the sensor and back. It then sends a signal to the Arduino with information about how long it took for the sonic pulse to travel.
The HC-SR04 ultrasonic range finder has four pins:
Vcc – supplies the power to generate the ultrasonic pulses
GND – connected to ground
Trig – where the Arduino sends the signal to start the ultrasonic pulse
Echo – where the ultrasonic range finder sends the information about the duration of the trip taken by the ultrasonic pulse to the Arduino
After researching about the Ultrasonic sensor I proceeded with the conections.
Ultrasonic sensor diagram:
(just add it to the previos connection made)