Sonar Test Plan - Woody, Abby, Michael




Introduction: Sonar Test Plan - Woody, Abby, Michael

The goal of this test plan is the see if we can measure distance using a sonar. This test plan will give you a set of instructions on how to build a simple digital ultrasonic sensor, calibrate it, program it, and use it to measure the distance from one point to another. Note that though the image excludes this, there is an LED attached to the arduino board.

This image was taken from:

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: Collect Materials

You will need to collect:

1. arduino board

2. ultrasonic sonar

3. various wires (enough for connecting

4. USB cable

5. red and blue led (or any two colors available)

6. breadboard

Images taken from:

Step 2: Step 2: Assemble Arduino Board

Using the breadboards and the arduino board, connect vcc to ground, trig to pin 9, echo to pin 10, and ground to 5V.

For the LEDs, connect the blue to pin eleven and yellow to pin eight.

Step 3: Create Code

1. In the void setup(), initialize the pin 9 and 10- recall "PINMODE( ), making sure to make the "TRIG" the OUTPUT (it sends the signal out) and ECHO (it receives the signal) the INPUT.

2. Include your Serial.begin(9600); here as well.

3. In the void loop (){ you want a few things to happen-

*You want to SEND out a LOW signal from the output pin. Use the command "digitalWrite..."

*You want that signal to last (delay..) for 2 microseconds (research the command for this).

* Then you want to SEND out a HIGH signal from the OUTPUT pin, this time with a delay of 10 microseconds.

Create a float variable called "duration" that will be the same amount of milliseconds that it takes the sounds signal to go out, bounce off something and be received.

duration= pulseIn(ECHO, HIGH); // This sets the "duration" as the time it takes the pulse to be received.

Now Serial Print this value.

Note: These instructions should give you a code that measures for time, but the image here measures distance. We will next calibrate our code so the that we can get an equation to measure for distance.

Citation- A. Valenti, Columbia Secondary School, 2018

Step 4: Calibrating From the Number of Milliseconds to Get a Value of Centimeters

Next: test it. You'll need to use measurements and data to come up an equation to convert duration values to distance values in inches or centimeters.

1. set up your sonar and a ruler and an object in front of the sonar to measure distance.

2. by increasing the distance between the sonar and the object, find 10 different data points by recording the distance and value that shows up on your computer for the what the sonar is reading.

3. using these data points, produce a line of best fit and its equation from using loggerPro or any other data analysis computer programs.

4. using this equation you can convert the duration values to distance values in your code.

5. Set up a variable for distance using the equation found. (this is so we can use the variable to set up parameters for LEDs later)

6. In your code make sure you use Serial.println to display the distance in the monitor.

Step 5: Add LEDs (Physical)

1. take two different colored LEDs and set them up on your breadboard.

2. Make sure that the LEDs are connected to pin 9 and 10.

3. Record the color and the pin that it is connected to for coding reference.

Step 6: Add LED Code

1. initialize the pins for the LED (9 and 10) as Output

2. in code, use if/then statements to set up parameters for when the LED should turn on or off.

3. The parameters should use the distance and inequality statements so that when the sonar measures anything above the threshold, one color will turn on. When it is less than the threshold, the alternate color will light up instead.

4. use digitalWrite to make the LED turn on or off

Step 7: Set Up Sonar for Measuring the Distance of the Door

1. place the sonar in front of the door in such a way it can read the distance of the door when it is closed and when it is open.

2. measure the distance of the door when it is completely closed.

3. using this measurement, enter the data into the code for the parameter needed to signal the LEDs for when to light up.

4. One LED should light up when the door is completely closed.

5. When the door is open, the other LED should light up instead.

Be the First to Share


    • Magnets Challenge

      Magnets Challenge
    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest

    4 Discussions


    1 year ago

    I guess that wam2018 is too busy and important to respond to any comment. So be VERY careful building projects he has downloaded. They will probably burst into flames.
    No, this is not putting him down, he just will not respond about his project, if he even built or attempted to build it.


    2 years ago

    I do not understand.

    Why are you connecting the VCC to Gnd and the Gnd to VCC?

    Is this a new way to connect arduinos?

    Or a new Electronics?


    2 years ago

    Why are you connecting VCC to Gnd and Gnd to VCC?

    I do not understand the reasoning behind reversing them.


    2 years ago

    Neat simple setup, best of luck on your project! I hope you get an A :)