Arduino Radar / Sonar, using Arduino & Processing | Full Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

Not to nitpick, but that's Sonar. Cool project though.

👍︎︎ 7 👤︎︎ u/Burner_Acount 📅︎︎ Nov 28 2020 🗫︎ replies

Movement! Signal's clean. Range: 20 meters.

👍︎︎ 2 👤︎︎ u/[deleted] 📅︎︎ Nov 28 2020 🗫︎ replies

Very nice

👍︎︎ 2 👤︎︎ u/Astro_Geek7 📅︎︎ Nov 28 2020 🗫︎ replies

Just discovered your videos. I really think you do a good job of explaining things.

👍︎︎ 2 👤︎︎ u/bigforknspoon 📅︎︎ Nov 28 2020 🗫︎ replies

Perfect!

👍︎︎ 1 👤︎︎ u/Ok-Radish9822 📅︎︎ Nov 28 2020 🗫︎ replies
Captions
[Music] i'm going to show you how to make this radar using an arduino i've used an arduino uno myself but any arduino will do i'm using a small servo motor the sg90 and i'm also using the hc sr04 which is the ultrasonic distance sensor finally i've 3d printed a bracket which i've got off thingiverse i'll post a link in the description here i am slicing it before printing it and that bracket is to attach the ultrasonic distance sensor to the servomotor so the wiring is quite simple black to ground red to 5 volts for the supply and i'm going to do the same for the ultrasonic sensor here the ultrasonic sensor can take either 5 or 3.3 volts so not to worry next i'm going to wire the motor signal wire to pin 9 digital output pin 9 and then we have the trigger pin from the ultrasonic sensor on pin 11 and the echo here is seen in yellow on pin 12. so now that i'm happy with that i'm going to just implement that in real so first i'm going to attach the bracket that i printed to the server motor so this bracket just screws on and then the ultrasonic sensor just fits nice and neatly into it next i'm going to wire up the motor so that's red to 5 volts black will be wired to zero volts or ground and then orange is the motor signal wire which we're going to be connecting to pin 9. next on the ultrasonic sensor we're going to use red for vcc which is 5 or 3.3 volts we're going to use black for ground or zero volts we're going to use yellow for the echo pin and white for the trigger pin the echo pin will be connected to pin 12 while the trigger pin will be connected to pin 11. next let's look at the code okay so first we have include servo.h which imports the servo library next we have the declaration of three integers the first being trigger pin on 11 echo pin on 12 and the motor signal pin on 9. so this just tells the program where your pins which pins you're using then we declare an integer which is a start angle so that's the position of the motor when it starts and then we have the minimum and maximum angle so what these are limits of the rotation to stop the motor from spinning at 360 degrees what we want is for the motor to rotate between the range of six and 175 degrees next we have an integer which declares the degrees per cycle so that's how fast the motor will rotate we instantiate the servo class in the motor library as motor next in the setup loop we set the two pins as outputs an input such as trigger pin as an output and the echo pin as an input and we attach the motor signal pin to the motor this is a function within the servo class itself and we then begin the serial communications at a baud rate of 9600 in the main loop we pass the start angle to be the current angle and we also pass the speed which is degrees per cycle to the motor rotate amount we then write the current angle to the motor which moves the motor to the position of the current angle and then we delay for 10 milliseconds the next function has a function within it so the function serial output sends the angle and the calculated distance which is another function i've declared below over serial communications but i'll show you that in a minute so after that function is run the current angle is then updated for the next cycle and if the angle has reached the limits the minimum or maximum it is inverted and changes direction so now we have the calculated distance function so what this does is it triggers the pin high for 10 microseconds and then triggers the pin low the trigger pin it then uses the pulse in function to record the duration taken for the echo pin to return high finally it converts the disc the duration to a distance using a constant and then returns the distance as an integer back into the other functions so you can see here as it's called calculate distance but it returns it back true serial output along with the current angle so the serial output function takes the integer of the angle and the integer integer of the distance converts them both to strings and sends them along with a comma true to serial communications to whatever device is listening so that string angle plus a comma plus a string of the distance now in order to get the radar output graphic representation we're going to have to download a file called processing so i'm using processing three ide i'm using on a mac so i downloaded this ide and you can use my file which is in the link in the description below so what this is is a java file so i'll run through the script quickly i won't run through it at all i'll just give you a quick overview on what's happening so initially you're importing um the serial library the key event library and the exception library you're going to instantiate a port and then declare a font the angle and the distance and then in the setup loop you're setting up uh the image itself that's the dimension so if you want to vary the dimensions of the image you change those to those two numbers there now this part is the important part so this name here of the port this needs to match the port name for your arduino so you'll get that by going in the arduino ide and going to tools and looking at the port you have to also make sure the baud rate matches the serial coms that we opened in the arduino script okay so once that's matching what the script here does it clears the port it looks for the carriage returner new line and then it also imports a font loads of font there's a function then to draw which draws the outline of the radar or the outline of the box should i say this also draws this function includes draw radar draw a line draw object draw text then you have the event which is triggered by new information being passed from the arduino through the usb port and what that does is it reads it in and separates us by the comma so it declares two variables out of a string one long string that's been sent and separates it into angle and distance and then converts them back to integers using a string to int function that's below then next is a draw radar function and what this does is it draws the outline of the radar the arc lines and the angle lines you can have a play around to see the effects it has on it okay so then after that we have the draw object function so what this does it actually draws the object on the on the graphic and then we have to draw a line function followed by the draw text function and finally we have the function which converts the string to an integer and that's a nice overview over that once you're finished changing the port name you can hit play and you should see the graphic begin so here's a nice demonstration of the project [Music] [Music] [Music] [Music] this video has been brought to you by mishmash labs i hope you've enjoyed it and if you have please hit the subscribe button or the like button below the links are in the descriptions for the cold 3d printed part thanks for watching [Music] [Music] you
Info
Channel: Mish Mash Labs
Views: 4,580
Rating: 4.9285712 out of 5
Keywords: arduino, radar, how to make radar using arduino, arduino uno, top arduino projects, best arduino projects, create radar, radar arduino, arduino radar project, processing, processing 3, arduino projects for beginners, arduino radar project code, arduino project, radar project arduino, radar project using arduino, arduino poject radar, best arduino projects for science exhibition, best arduino projects for home, best arduino, arduino prjects, best arduino radar video, project
Id: Tr0MF8FU_60
Channel Id: undefined
Length: 9min 27sec (567 seconds)
Published: Fri Nov 27 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.