Arduino Tutorial – Ultrasonic Sensor HC-SR04
|Arduino Tutorial – Ultrasonic Sensor HC-SR04
In this Arduino Tutorial we will learn how the HC-SR04 Ultrasonic Sensor works and how to use it with the Arduino Board.
Hardware Required:
– Arduino Board
– Ultrasonic Sensor HC-SR04
– Breadboard and Jump Wires
Flash Deals — https://goo.gl/CVqg7P
Mega Stock Clearance — https://goo.gl/eCbuiP
Arduino Kits — https://goo.gl/uwr19e
Anet A8 3D Printer Promotion — https://goo.gl/MNa3p9
More Budget 3D Printers — https://goo.gl/v6fPU4
Connections:
– The HC-SR04 Ultrasonic Module has 4 pins, Ground, VCC, Trig and Echo. The Ground and the VCC pins of the module needs to be connected to the Ground and the 5 volts pins on the Arduino Board respectively and the trig and echo pins to any Digital I/O pin on the Arduino Board.
– The HC-SR04 sensor attach to the Breadboard
– The Sensor VCC connect to the Arduino Board +5V
– The Sensor GND connect to the Arduino Board GND
– The Sensor Trig connect to the Arduino Board Digital I/O 9
– The Sensor Echo connect to the Arduino Board Digital I/O 10
Code :
– First you have to define the Trig and Echo pins. In this case they are the pins number 9 and 10 on the Arduino Board and they are named trigPin and echoPin. Then you need a Long variable, named “duration” for the travel time that you will get from the sensor and an integer variable for the distance.
– In the setup you have to define the trigPin as an output and the echoPin as an Input and also start the serial communication for showing the results on the serial monitor.
– If the object is 10 cm away from the sensor, and the speed of the sound is 340 m/s or 0.034 cm/µs the sound wave will need to travel about 294 u seconds. But what you will get from the Echo pin will be double that number because the sound wave needs to travel forward and bounce backward. So in order to get the distance in cm we need to multiply the received travel time value from the echo pin by 0.034 and divide it by 2.
Get to Code :
http://mertarduinotutorial.blogspot.com/2016/11/hc-sr04.html
—
Arduino Tutorial – Ultrasonic Sensor HC-SR04
Arduino Tutorial – Ultrasonic Sensor HC-SR04
Hello! All good! I only do not understand why LCD is not I2C?
nice content
is there any other way to display the output rather than serial monitor,like a separate color full field on computer itself??
the connections are same for arduino uno also right??
+Mert Arduino Tutorial & Projects could you please upload the tutorial of sd card module with arduino UNO playing .WAV file through peaker
thanks in advance
sir plz tell how to add camera to ardiuno to make object detection robot and also how to interface speech control robot with any ic like hm2007
Vay kardeşim bunu bir türk olarak yaptığın için beni gururlandırıyorsun
i came here to listen the music 😊
didnt work
IS it normal for it to display really high numbers cause I typed it in and copied the code and it still displays numbers like 2000 once a while
sir plz say which app you use to measure distance
it is not showing proper distance when i connect my arduino
Awesome video man, thanks!
worked perfect good job amazing video
Why does it says Distance 0? is my HC- Sr04 deffective?
why you put to trig LOW for 10Microseconds?
can i connect 7 sigment display how ? give mi circuit diagram for making distance mesring using 7 sigment display
I get Distance 0 over and over again
Perfectly working thanks 👌
when i tried to verify there was something wrong with the digitalwrite Trigpin, LOW);
"Distance: 2644+-" and still changing 🙁