TestPlan Sonar by Ashley Q, Emily C, Kiara T.

Introduction: TestPlan Sonar by Ashley Q, Emily C, Kiara T.

Gather all of your materials:



4 wires

Computer Cable




Step 1: Connecting Your Circuit

This step is to assemble the set up.

Place the Sonar on the breadboard as shown in the image.

You should have a wire connected from the 5V output of your arduino to the VCC of the Sonar.

Connect another wire from pin 9 of your arduino to the TRIG of the Sonar.

A third wire should be connected from pin 10 of your arduino to the Echo of the Sonar.

A fourth wire should be connected from the GND of your arduino to the GND of the Sonar.

*Note: all of the wires should be connected behind the Sonar.

Step 2: Programming Your Arduino

Type the Following code into Arduino and make sure that there are no errors.

Step 3: Calibrating Your Data

you need to calibrate your data , which means we have to take a series of voltage measurements using the Arduino and the measurements have to be at various distances.

To actually calibrate your data You will need an object, like a notebook, and then using a ruler place it at different distances away from the Sonar, and record the values that appear.

we have uploaded the data we recorded

Step 4: Creating Our Graph for the Calibration Data

We graphed our data points on graph paper and drew a line of best fit as our calibration curve. We then found the equation of this line which was y=2/3*duration.

Step 5: Using Your Equation

In this step you now must use your general equation and add it to your code. In your void loop () section, you should add:

float distance;

distance= (2/3*duration) + 0;

while, this is only the equation of our line, yours should be quite similar.

Step 6: Finally Using Your Device

You have to determine whether or not the door is opened, or if an object is falling. One way to do this it to modify your code so that you're able to get an LED to light up if a door is opened and light off if the door is closed.

you can do this by adding the following code into the "void loop ()" section:

if (distance>10) { digitalWrite (10, HIGH);


else { digitalWrite (10, LOW); }

Be the First to Share


    • Barbecue Speed Challenge

      Barbecue Speed Challenge
    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest
    • Arduino Contest

      Arduino Contest