Ultrasonic sensor:
https://bit.ly/3eNsqrs
Recommended soldering iron- TS100:
https://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.
, https://i.ytimg.com/vi/Lx7KEaRLOU0/hqdefault.jpg
source
Heres the code. Enjoy:
#include <NewPing.h>
#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);
}
thank you ! finally a library that improve the accuracy XD
What could be the maximum Distance it can sense
Excellent. Thanks for the help!
How can I hook up a led so that it blinks when I send a signal to the ultrasonic sensor?
Thanks in advance
What i do if i want an LED to turn on if distance<40 ??
Great tutorial – thanks!
how can I code it in Arduino Uno R3
Substantially better than other tutorials, thank you for making this!
How could I make it where when the ultra sonic sensor detects something it plays aduio
this library has made so easy
Hi, great video. Do you know how to get it to work with Arduino Nano Everyday? Thanks
Thank you for not making people have to input in weird math to get a simple sensor working like every other tutorial
Thank you great video!
what board is this I cannot find it anywhere?
Can you send me the parts list for this please?
Good introduction
Just wondering, I want to make one of these but I also want there to be a vibration motor in the circuit, but I want the vibration motor to only activate if anything gets 6 feet or closer to the sensor. How can I do this? Could you you also please explain what the schematic would look like (because I am not sure where the vibration motor would go)?
But it's only showing distance 0
Hello sir,, can u please make a video with perfect code.. And ardino uno,,ultra sonic sensor and servo motor… Combined working mechanism..
Easy explained
This was perfect thanks
Can we use Arduino nano instead of Arduino uno
ITS NOT WORKING BC IT SAYS NewPing.h No such file or directory plz help
thank you very much bro
god bless you
wow I am a kid of 9 years old and I enjoy this, keep the good work up
Max distance?
great job…very clear explanation.thanks.
👍
thanks, it was really helpful
amazing video.
but would u give the link of the 3D Software u did it, please!!!!!!
Hello! Thank you for the video but mine keep displaying a message like this: " f⸮ ~ ⸮⸮ fxf⸮ ~ ⸮⸮ fx" What im doing wrong?
What 3d program did use to demonstrate?
how could i make it so that if the distance > 0, it does myservo.Write(90);
i cant get NewPing to work is there a way i can copy and paist
Can the Echo pin be connected to Encoder IC HT12E pin 10 as an input signal.
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
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
}