How to Use Sonars

Introduction: How to Use Sonars

What is a sonar sensor, you ask? A sonar sensor, otherwise known as an ultrasonic range detector, is a device that sends out high frequency sound pulses to a target object and measures the time it takes for the echo of that wave to return. The sensor can be manipulated to read the distance to the target object as well. That is what we are going to do.

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: Gather Your Materials

What do we need:

  • Sonar Sensor (duh)
  • Meter Stick
  • Target object (can be pretty much anything)
  • Arduino Set
    • connecting wires
    • USB cord
    • Arduino board
    • Arduino Computer Progream

Step 2: SETUP(Part 1)

The basic setup connecting the sonar sensor and the arduino is simple and easy to make. The sonar sensor has four nodes sticking out from the bottom, labelled "VCC", "Trig", "Echo", and "GND", from left to right. Separate wires should be connected to each of these on one end, and to the "5V", "~9", "~10", and "GND" pins, respectively, on the arduino board. The numbered pins connected to the "trig" and "echo" do not have to be 9 and 10, but they do have to be two consecutive numbers from that side of the arduino board.(image included)

Once that is properly connected, simply connect the arduino board to the computer using the USB cord(specific to arduino board). You should have the arduino program open on your computer so that you can make sure the USB port is receiving data from the arduino board.

Now you're ready to code.

Step 3: SETUP (Part 2)

To check to see if the sonar sensor works we want to calibrate it and check the values. We want the sonar sensor to read out the time values in micro seconds which will happen with the help of the first code.

Step 4: Duration --> Distance

First, we want to create a data table with the duration values for five exact locations. Each consecutive place should have the same distance between them. For example, using the meter stick we placed our target object 5 in from the sonar sensor and wrote down the duration time shown by the first code. And then 10 in, and four more places each 5 in. away from each other (following a straight line) and further from the sonar sensor.

Second, these points were plotted and graphed allowing us to create a equation of the line connecting those points. Y= 0.00685x + 0.49

The x in this equation, once plugged into the code, will be the "duration" variable that will convert the number read by the sonar sensor into inches.

Step 5: Finale

The final code from the previous step will read out the distance in inches. SUCCESS!!!

Be the First to Share


    • Trash to Treasure Contest

      Trash to Treasure Contest
    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest