Epic Sonar Proj3ct\$\$\$

123

3

Introduction: Epic Sonar Proj3ct\$\$\$

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!

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

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

-ARDUINO UNO BOARD

-1 Ohms Resistor

-A LED

-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!

https://www.arduino.cc/en/Main/Software

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.begin(9600);

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

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

digitalWrite(trig,LOW);

delayMicroseconds(2);

digitalWrite(trig,HIGH);

delayMicroseconds(10);

duration=pulseIn(echo,HIGH);

Serial.println(duration);

delay(200);

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

Recommendations

3 199
24 1.6K
6 468
Meat Class

8,689 Enrolled

3 Discussions

Thanks guyyyysss!! I got an A in my comp sci class, u guys da besssstt!!! btw i followed u on ig and snap, give me the follow back and we can play roblox together!

Great tutorial, got an A+
Thanks my boi Daniel!