EASY! Ultrasonic Sensor with Arduino
ฝัง
- เผยแพร่เมื่อ 7 พ.ย. 2018
- Ultrasonic sensor:
bit.ly/3eNsqrs
Recommended soldering iron- TS100:
bit.ly/3e81eUD
In this video, lets connect the HC-SR04 Ultrasonic sensor to our Arduino and learn how to code the ultrasonic sensor. We also learn how to run the sensor.
The ultrasoinc HC-SR04 sensor can be used to make obstacle avoidance robots, or ultrasonic radar or other ultrasonic arduino projects.
This tutorial for the HC-SR04 sensor should teach you how to code easily and build your arduino projects. - วิทยาศาสตร์และเทคโนโลยี
Heres the code. Enjoy:
#include
#define TRIGGER_PIN 10
#define ECHO_PIN 11
#define MAX_DISTANCE 20
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
void setup() {
Serial.begin(9600);
delay(50);
}
void loop() {
Serial.print("Distance is:" );
Serial.println(sonar.ping_cm());
delay(1000);
}
can i make NewPing sonar1 and NewPing sonar2 and so on if i want to use more than 1 sesnor ?
Yes, just make sure u input right pin ids
Examples>sensors>ping has more elaborate code..
Code is wrong
Thank you for your effort
JESUS IS THE KING OF THE KINGS
I keep returning to this video since it seems to always answer my questions!!!! Thankyou so much for making this content.
hi, what program did you use to make the circuit?
Thanks! I didn't know about this library and it just saved me a LOT of work
Thank you for not making people have to input in weird math to get a simple sensor working like every other tutorial
Well tbf - that only makes it useful for Arduino. I hoped i could get some details allowing me to make it work in my ecosystem which is a bit more niche. I did find this tutorial useful but that "weird math" in fact would also be highly appreciated
What's wrong with the math? It's just stuff you should have learned in High School.
Substantially better than other tutorials, thank you for making this!
sir what application did you use in 3:17 to show connection of each components? thanks
What 3d program did use to demonstrate?
Amazing, thanks for showing this library :)
Hi, great video. Do you know how to get it to work with Arduino Nano Everyday? Thanks
Can the Echo pin be connected to Encoder IC HT12E pin 10 as an input signal.
thank you ! finally a library that improve the accuracy XD
great job...very clear explanation.thanks.
Can we use this method for underground scan? Metal, gold etc..?
Can you let me know of the components you used in the video.
I get alot more from your video you don't just run thru it thank you
Is it possible to get to 200 khz with arduino or a similar setup?
Great tutorial - thanks!
Excellent. Thanks for the help!
This was perfect thanks
How can I hook up a led so that it blinks when I send a signal to the ultrasonic sensor?
Thanks in advance
thnks alot the library you mentioned was amazing.....
this library has made so easy
hello I did the same but I keep getting 0cm as a readings should I buy a new sensor?
Can I use ARDUINO UNO for this Project? It is same codes that you used sir?
Awesome video as always , can you make a video for LCD and keypad ?
What application did you use to draw your schematic?
arduino ide
Wow, This made me impressed. C++ Beginner here, Thank you.
thank you very much bro
god bless you
Excuse me, I want to make 2 ultrasonic for the length, 2 for the width, and 1 for the height. Can you do it for us?
i done this project its works thank you
Good video!
Can you send me the parts list for this please?
How could I make it where when the ultra sonic sensor detects something it plays aduio
i actually used these around the house for various home automation
bruh...
What i do if i want an LED to turn on if distance
amazing video.
but would u give the link of the 3D Software u did it, please!!!!!!
Its the Arduino serial monitor
www.arduino.cc/en/software
to download the software
i cant get NewPing to work is there a way i can copy and paist
What chip is that?
thanks, it was really helpful
thanks for the like on my comment
thankyou
now i will get easily
Good introduction
how can I code it in Arduino Uno R3
beautiful demo, woo
wow I am a kid of 9 years old and I enjoy this, keep the good work up
Keep learning and start doing some stuff now :)
If you understood all of that then oh my you are smart.
How to fix 'sonar' was not declared in this scope
why when i upload it it say compilation error:NewPing.h No such file or directory ?
Thanks for sharing. I wanna do this project but when there's something into the range of 20cm it will send an alert/email to my cellphone... I've bought wemos d1 r32 for that project but I'm totally clueless on how to do it
If someone can help me that would be appreciated
Thank you
very helpful video
Max distance?
ningal oru killadi thenna 😌
after long research we have a new technology to send data over dc lines so no need to connect 4 wires of ultrasonic module just use same dc line between module and MCU to supply module & get data
Can we use Arduino nano instead of Arduino uno
Yess ! Connect echo and trig to two digital pins e.g D2 and D3 and connect VCC and GND
Thank you great video!
thanks you brother
const int TriggerPin = 8; //Trig pin
const int EchoPin = 9; //Echo pin
long Duration = 0;
void setup() {
// put your setup code here, to run once:
pinMode(TriggerPin,OUTPUT); // Trigger is an output pin
pinMode(EchoPin,INPUT); // Echo is an input pin
Serial.begin(9600); // Serial Outpu
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(TriggerPin, LOW);
delayMicroseconds(2);
digitalWrite(TriggerPin, HIGH); // Trigger pin to HIGH
delayMicroseconds(10); // 10us high
digitalWrite(TriggerPin, LOW); // Trigger pin to HIGH
Duration = pulseIn(EchoPin,HIGH); // Waits for the echo pin to get high
// returns the Duration in microseconds
long Distance_cm = Distance(Duration); // Use function to calculate the distance
Serial.print("Vzdálenost = "); // Output to serial
Serial.print(Distance_cm);
Serial.println(" cm");
delay(1000); // Wait to do next measurement
}
long Distance(long time)
{
long DistanceCalc; // Calculation variable
DistanceCalc = ((time * 0.034) / 2); // Actual calculation in cm
//DistanceCalc = time / 74 / 2; // Actual calculation in inches
return DistanceCalc; // return calculated value
}
Thaks bro ! I have a question Why duration is 0(zero) ?
Can you make a video showing how to program a robot with Arduino code?
There are so many things in the pipeline. Robots are definitely in my mind :)
when i type newping it doesnt work anytips?
Awesome Video
GND is turning off my arduino. What causes the problem?
Is it possible to scale it up to 10m ?
no maximum 200 cm maybe
What’s the command for inches? You could of at least told us the name.
Why does it read 0 too when you hand is sensed?
Can l get the names of the materials used here pls it's urgent
Thanks.
Easy explained
Anyone know what software is that at 3:16?
tinkercad
it says newping.h is not a file or directory
Can you have 2 sensors Nd one sends the signal the other one receives and you can track the transmitter. I'm trying to make a game with my son where I can find him by tracking him where he's hiding
Each sensor has 2 units. Receiver and transmitter like I showed.
I'm basically asking can this be made by Using this sensor th-cam.com/video/a_U724jTPWI/w-d-xo.html
ITS NOT WORKING BC IT SAYS NewPing.h No such file or directory plz help
download the library google NewPing.h and import the library into Arduino
Great video,! Thanks for sharing 👍🏻
👍
Accurate!
Hello sir,, can u please make a video with perfect code.. And ardino uno,,ultra sonic sensor and servo motor... Combined working mechanism..
This is the video of my RADAR project with ultrasonic sensor and servo motor : th-cam.com/video/bj1nxubM8IQ/w-d-xo.html (I hope it is helpful for you)
Hello! Thank you for the video but mine keep displaying a message like this: " f⸮~⸮⸮fxf⸮~⸮⸮fx" What im doing wrong?
Check your LCD pin connections
Set baud rate of serial monitor correct ! Mostly it is 9600
What could be the maximum Distance it can sense
4 meters
It doesn’t work for me
7:56 words for life.
Is there a sensor that automatically releases water when plants are detected
NewPing's broken.
But it's only showing distance 0
@Dash did you fix it ? mine is also showing only 0 !
You have to put something in front of the sensor at a distance of less than 20 cm.
@@jacksonconley5117 but it's still isn't working
only showing o cm
LOVE GOD AND EVERYONE!!!
#include
int data ;
int led1 = 2;
int led2 = 4;
NewPing sonar (10 ,11 ,100);
void setup()
{
Serial.begin(9600);
}
void loop()
{
Serial.print("distance is : ");
data=(sonar.ping_cm());
Serial.println(data);
if(data0){
digitalWrite(led1 , 1);
digitalWrite(led2 , 0);
}
else{
digitalWrite(led2 , 1);
digitalWrite(led1 , 0);
}
}
😎😎😎😎 niiicceee
Trying to keep these videos under 5 mins :(
hey i have a error can you please help?
this is my code.i wrote it exactly like you and installed the library.
but it shows an error called :"expected initializer before 'sonar' "
my code :
#include
int trigpin=9;
int echopin=8;
int
NewPing sonar (trigpin,echopin,20);
void setup() {
Serial.begin(9600);
delay(50);
}
void loop() {
Serial.print("Distance is:" );
Serial.println (sonar.ping_cm());
delay(1000);
}
pls help me as soon as u can.:((
❤❤☦❤☦☦😊
Hello. Tutorial not work. You Bad, but one Kebab please, with baraninka
GOD IS REAL!!!
JESUS IS THE KING OF THE KINGS!!!