Introduction: HOW TO MAKE a SONAR WITH ARDUINO

This is how to make a sonar thing using Arduino.

Step 1: Gather Materials

The Materials needed are:

1: Dupont Wires (4)

2: UNO R3 board

3: Ultrasonic Sensor

Step 2: Assemble Arduino Board

Assemble materials as shown.

Connect Digital Port 10 to "Echo" on the sonar

Connect Digital Port 9 to "Trig" on the sonar

Connect Power GND to GND on the sonar

Connect Power 5V to VCC on the sonar

Connect the arduino board to the computer with the usb cable.

Step 3: Program the Sonar

Copy code above.

The void setup declares which variables are the input and output.

The void loop programs the sonar to detect objects in front of it. We used an equation to calibrate it to measure the distance in centimeters, and printed this value to the serial monitor.

In order to calibrate the sonar, we tested which value is given by the sonar when it is a specific distance away. We gathered multiple data points and found a line of best fit using logger Pro. We found that distance equals the equation shown in the code, and we wrote the equation into the code so that the value printed to the serial monitor was the calibrated value.