Introduction: Epic Sonar Proj3ct$$$

About: I play roblox on my free time.

Whats up guys Daniel here follow me on ig and snapchat ya dig.Did Grandpa Joe get you and arduino board instead of an xbox or solja boi game console? Well I'm bout to teach you how to make an EPIC sonar project like this in a few easy steps with that arduino you got!

Step 1: GET a Computer No Phones

If you don't have a computer then I'm sorry to inform you but you can't do this project so get out.You will also need an


-1 Ohms Resistor


-6 Jumper Wires

-1 Breadboard (not from the pizza shop)

-A Brain NOTE:does not need to be fully functional

Step 2: It's Dangerous to Go Alone Take This!

Assuming you have a computer then download arduino from this link

your welcome

Step 3: Getting to Know Your Sonar

The Arduino sonar has a total of four pins.The Ground (GND) ,5 Volts (VCC),Pulse sender(TRIG), and Pulse reciever(ECHO).The GND and VCC go into the respective pins and the trig and echo will go into what ever digital pins you assign them.

Step 4: Physical Setup

For the sake of the example the pins assigned to the sonar were 9 and 10 however any digital pin is usable.The visual indicator for the sensor will be the LED and like the sonar must be connected to a ground and digital pin to complete a circuit.The led must have a resistor connected to the ground and the negative pin to ensure the LED does not explode in your face.Like the sensor the digital pin connected to the positive leg can be which ever.

Step 5: Understanding the Code (HACK THE PLANET!!!)

The most difficult step is the code that goes into the sensor.It is helpful to create variables for the digital pins on the Sonar And LED pins to make it easier to recall and remember ,so make variables called trig and echo equating them to the digital pins you connected them too earlier (in this example 10,and 9) do the same for the LED.

int trig=9;
int echo=10;

int led=7;

float duration=0;

void setup() { // put your setup code here, to run once:

pinMode (echo,INPUT);

pinMode (trig,OUTPUT);


Serial.println("Let's get it!"); }

void loop() { // put your main code here, to run repeatedly








The TRIG pin is being called to send a pulse and the ECHO pin sends another pulse microseconds after to receive the wave again.In this example a float variable is created to have a more precise variable when displaying the values on the cereal monitor from the ECHO pin.The serial begin and lnprint in are to show the values coming on the pop up serial monitor.(If you PC master race press Ctrl+Shift+M after uploading code to board if your computer is a fruit press the command button instead of Ctrl)

Step 6: Calibrating the LED

Assuming you work for microsoft and got this far you now need to program the led to react when things are within a certain distance for example calculating how far a ball is from hitting your face.To do this you must create a linear equation that equates the sensor values to an amount in inches.Not good at math its ok ur boi Daniel got you (y=144.2x-21) .Now depending how early you want the sensor to warn you before the ball hits your face you want to input an inches value into the x and see what sensor value you get.Create an if and else function in which the float variable is in the range that you want it to alert you and accompany this with a call to turn the led on and off if it is out of said range.(Below for Example)

*you can paste this code on the bottom of the previous code*

if(duration < 620) {
digitalWrite(led,HIGH); }

else{digitalWrite(led,LOW); } delay(100);


Step 7: *insert EPIC Sounding Title*

The final step is to test out the sonar after uploading the code to your board and having a correct setup.For example if you set the distance to alert you when it reaches 12 inches get a Subways Footlong Sandwich to measure the distance and put something solid at the end hold the sonar at the other end facing the object and the LED should light up because all footlong sandwiches are actually 11 inches and 11 inches is inside the range.

Step 8: Like and Subscribe!!!

If you found this tutorial helpful make sure to leave a like and a comment at johnnynyc 00 on youtube.Make sure to give a shoutout to ur boi Daniel.Also let us know if you got an A on this if it was a class quest.XD