Ultrasonic Sensor with Arduino | Easy Arduino Project
Okay, so once you have everything, lets just grab our breadboard right here and the ultrasonic sensor just put it into the breadboard okay, and then we grab our arduino here and then youll need four of these jumper cables right here. So i have a random black cable. Obviously, to for power, positive and negative for the ultrasonic sensor, so vcc red cable to the five volts on the arduino and then ground black cable to ground on our ultrasonic sensor. Ill use this green jumper cable to connect from our trigger pin on our ultrasonic sensor. To pin number 10 on the arduino and then this blue cable to connect the echo pin on the ultrasonic sensor to pin number 11 on the arduino, and so you should have something that looks remotely like this. Okay at my desk here now lets plug in the arduino okay. Arduino is plugged in its got power now lets load up the arduino, ide, Music, okay, so ill explain this programming part a little more in depth. Now the first line on the sketch above the setup, the void setup, it says – include new ping, so youre going to use this command to include the library new ping which is going to allow the ultrasonic sensor to connect to the arduino and then right below it. The second line below that is going to be the actual line of code that will initialize the ultrasonic sensor to connect to the arduino and now in the void setup.
If you look down here well, just set the serial baud rate mines just set to 9600. That should just be fine lets go down to the void loop here were going to use serial print functions to print. The data coming from the sensor were going to print that into the serial monitor. Okay, so now its time to open up the serial monitor and now, as you can see, the ultrasonic sensor has already started to plot the data. So if you look down in the lower right corner, you can see on my webcam im putting my hand in front of the sensor and as i move it closer and farther back the distance on the serial, monitor changes so theres the sensor and it works. So there you go okay, so thats about it. For this video thats been how to set up an ultrasonic sensor with an arduino here. So all you really need to do is get that new ping, library, arduino library and all the hard works already done for you.