Tutorial on Ultrasonic sensor HC-SR04 - Connections, interfacing & coding with Arduino
HTML-код
- Опубликовано: 14 июл 2024
- In this tutorial you will learn how to connect the ultrasonic sensor HC-SR04 OR ping OR range sensor to Arduino along with the coding part !
00:00 - Intro
00:19 - Requirements
01:08 - Connections of ultrasonic sensor HC-SR04
05:04 - Arduino Code for HC-SR04
07:08 - Testing
Code available here :-
mechstuff.com/connection-inte...
Like my page on Facebook :-
MechStuff/?r...
For more interesting mechanical news, engines & robotics stuff, visit my site - MechStuff ! ;)
mechstuff.com/ - Наука
thanks sir ....you explained well.....
Very good tutorial, simple and no winding talking. Code is short and easy to understand. Thank you very much for showing how to use the HC-SR04 sensor.
great, thanks for helping me with my project
thanks for that cool tutorial nice video
Awesome bro thanks for the video ,i found it very useful
Thanks bro it's very very useful
Thanku sir...It will working😊
it actually works. thankyou very much !!!
Of course it works! ;)
This video was really help full, thanks
will subscribe
It, s works very well thanks
Really nice video
Thank you man, very short code and helpful.
thank you soo much sir......its working.
you NAILED it.
the fist working project i made with an ultrs soniuc sensor thanks a lot bro
Great 👍
Bro can u send me the code plz ??
you are smart man ....continuous
Really nice video you earned a sub from me! Thanks bhai
very good explanation
thanks boss.... u r great
First off, cool intro man 😂
thank you bro! I'm Brazilian and you still help me!
Thanks a lot it worked
Really Good Work!!! Nicely Explained!!! Helped me in my Project!!! Thank you
Also subscribed to you...
Thanks and welcome 😉
Thanks sir. This will help me with my project.
Great! 😉
thank you soo much man this is very short and helpful may GOD bless you !!
Thanks, you teach me good, I am a beginner. And this video is helpful for me.
thanks brother u saved my day...:)
Thanks for nice video is simple but very helpful, if possible please make tutorial for new ultrasonic sr04t. Thanks
thx!like ur vid
Very good to have a program without header files, as they are many and sometimes not compatible
thank u so much
You are godsent
ধন্যনাবাদ দাদা 😂😂😂😂😂😂😂😂😂😂😂😂😂🎉😂🎉🎉😂🎉🎉😂🎉😂🎉😂🎉😂😂🎉🎉😂🎉😂😂🎉🎉😂😂🎉😂🎉😂🎉😂🎉🎉😂😂🎉🎉😂😂😂😂😂😂😂😊😂😊😂😊😂😊😂😊😂😊😂😊😂😊😂😊😂😊😂😊😂😊😊😂😊😂😊😂😊😂😊😂😊😂😊😂😊😂😊😂😊😂😊😂😊😂😊😂😊😂😊😂😊😂😊😂😊😂😊
THANK YOU I COULDNT MAKE IT WORK NOW I CAN.
keep it up
superb
tq. good vid
Nice bro
accurate... man.... thank you so much
please all subscribe him
Thanks!
Thanks bro, you save my life!!!
Cb
Kaise and kya
how
Thank u so much such wonderful experience
output comes perfectly .i am expecting more videos from you
can i say thanks for providing the video and also the code, most helpful
ok you can say thanks
THX MAN!!!!!
thanks bro
TNX u bhaiya
Sir esi hi video Bana kar bhejte rahna
can u tell me coding and diagram for ultrasonic blind stick gps tracking
tq u save my life too..aleeeeeeeuuuuuuutoooooo muah
good
thanks bro ,it's works..
A question if i want to connect a buzzer where would i go
you can connect a buzzer instead of led ,the wiring is same
you r doing great job bro
Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"
Sketch uses 3122 bytes (9%) of program storage space. Maximum is 32256 bytes.
Global variables use 190 bytes (9%) of dynamic memory, leaving 1858 bytes for local variables. Maximum is 2048 bytes.
An error occurred while uploading the sketch
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Very useful information, thank you. When I try this myself for my school project, the LED turns ON from the time the circuit is powered on. It does not wait till the sensor receives an input. What could be wrong? Please help!
Thanks
sorry..i got it.
thank you.
Thank you..
thank you bro
It's very helpful for beginners
But, please upload more videos for arduino tutorial
yes... sure... I had some technical problems... I'm gonna post videos soon.. Subscribe so that you'd come to know when I post them & stay tuned :)
Hey, I just constructed the ultrasonic sensor and uploaded the code, but I have a problem. The pager motor I used for vibration keeps on vibrating, and the sensor doesn't detect any objects or distance. What should I do?
Thanks! 😊
Can you show the values that you are printing on the serial monitor??
how to control pneumatic solenoid valve using ir sensor
thanyou
does the code also contains sms text message phone feature?
Thank you so much bro!
Thx, you helped me!
Great tutorial. I can't find the HC-SR04 part for sale on the Arduino website, is this part still available?
You can buy it in a very reasonable price from this link : botuniverse.in/index.php/product/hc-sr04-ultrasonic-sensor/
This code for who found that the led stay on , this because you didn't clear the trigger , check the following code
int trigger=9;
int echo =10;
void setup(){
Serial.begin(9600);
pinMode(trigger ,OUTPUT);
pinMode(echo,INPUT);
pinMode(7,OUTPUT);
}
void loop(){
long duration,distance;
digitalWrite(trigger ,LOW); //clears the trigger , else its not gonna measure more than one value
delay(0.2);
digitalWrite(trigger,HIGH);
delay(0.1);
digitalWrite(echo,LOW);
duration=pulseIn(echo,HIGH);
distance =(duration*0.034)/2;
Serial.print(distance);
Serial.println("CM");
if(distance 10){
digitalWrite(7,LOW);
}
delay(1);
}
Tq
I'm using an arduino provided by elegoo, i was working on a home security System as a school project. And i did somthing similar to what you did and everything works fine when i connect the ultrasonic sensor alone. However, when i add other sensors and motors a started getting wrong reading which turn on the alarm for no reason. What do you think is the problem?
For those who has similar problem s, try using Relays with external output source and take the average of the sensor readings. The more readings you take the better but with more delay.
That solved the problem for me. Hope it works for you
bhai kya aap aisa border security system sensor bana sakate ho ki border ko kisi bhi kone ko touch kare udhar hi gun fire kare please mi replay
can i modify this circuit for gps tracking and water and light senser blind stick???????
bro can you upload a video about how to connect ultra sonic sensor with arduino and motor without any motor driver and diode and transistor
Brother can you prepare obstacle avoiding robot with help motor shield
Hi bro I want to do this project. Can u helpe
nice explanation .can u upload how to dump programme into the aurdino so that i can complete my project
thank
you
Also for line 20, why do you have a * operator instead of a =?
can you give me the link of the aduino
Sir plz programming ka video banayeg
Plz , make a video on 2.4" tft Screen
please paste the code in the description
Better to use different color wires to avoid confusions
Overall i liked this video
can you pls tell which software to use for coding and how to upload the program to the board.
arduino
Bahiya ye mila kahan se apne khud program kiya ya example mai se liya hai
Can we increase the distance of 10 centimetre ?
sir if you want to add buzzer whats the code
plz tell me sir
What should i do if i want to set the distance on 1 meter or 1 centimeter ?
Problem occurs when coding uploading to board...what can i do?
best
I'm trying to transfer the distance I get from hc-sr04 sensors to thingspeak using Nodemcu. Only when measuring distance the sensors work very well but when I write the code to transfer the data to thingspeak or firebase the sensors work very slowly. What could be the reason for this? how can i fix it
Nice tutorial! Instead of using a LED you can use the builtin LED on the arduino. Instead of int led just use the function LED_BUILTIN where you digital write.
Bro pls give best buy link for aurdino
Bro,what is 29.1 value stands for in distance formula
It's the inverse of the speed of light in centimeters per microsecond units (see full explanation below) - i.e. 29.1 ~ 1 / 0.0343
Let's use the following abbreviations and operations:
S - speed
D - distance
t - time (or "duration" in the video)
m - meters
cm - centimeters
s - second
μs - microsecond
* - multiplication operation
/ - division operation
We know that the speed of sound is 343 m/s or 0.0343 cm/μs.
Distance equation is: D = S*t
Function "pulseIn()" returns the full time traveled by the sound in microseconds.
Since we know the speed (the speed of sound) and time traveled ("duration" value returned by the "pulseIn()" function), we get D = 0.0343 * duration.
We actually need only half of the distance because the "pulseIn()" function returns the time traveled to the object and back, but we need only the distance to the object.
Hence, we divide the full distance traveled by the sound by two, and our distance to the object is equal to: 0.0343 * duration / 2.
We can rewrite this as: (duration / 2) * 0.0343 or (duration / 2) / (1 / 0.0343)
Since (1 / 0.0343) is equal to approximately 29.1, we get the distance to the object (in centimeters) equal to: (duration / 2) / 29.1
Clear label sansor u can say
Will the led not burn?
how will you put code in ardino
Very Good tutorial but you should given the circuit diagram also
Please visit link in the description for the circuit diagram!
very nice ,plz where to find the code