# Arduino Range Finder

93

3

1

Published

## Introduction: Arduino Range Finder

This range finder was created to monitor whether or not a door is open. Measuring the distance of a door will allow us to identify whether a door is open or closed.

## Step 1: Gather Your Materials

To complete this project one must acquire:

Arduino Uno microcontroller

USB cable (to connect the Arduino to the computer)

Laptop computer

Resistors (10,000 Ohm)

Sonar

## Step 2: Connecting Your Circuit

Follow the above diagram to connect your circuit. You will notice that the vcc is connected to the 5v pin, the trig is connected to the 9 pin, the echo is connected to the 10 pin, and gnd is connected to ground.

## Step 3: Programming Your Arduino

Copy and paste this code into your editor then upload it to your Arduino. This will produce distance values from your Arduino that we will then need to calibrate

## Step 4: Recording Your Calibration Data

Currently your Arduino is not producing distance values, it is producing duration values. We need to create a calibration curve to find the equation of the line. To do this take a ruler and set up your Arduino at the base of it, every 5 inches record the duration that the Arduino produces. We will then take this data and input it into an excel spread sheet.

## Step 5: Creating Your Calibration Curve

In excel make sure that in column 1 you put your distance and in column 2 you put your distance. Then highlight the columns and then select insert scatter plot. Right click on one of the data points and click format trendline, then select linear. Finally select display equation on chart. Finally record the equation given to you.

## Step 6: Calibrating Your System

Now that you have found your equation you will convert duration into distance.Take your equation and input it into your code underneath where we left off originally. For example my equation was y=0.007x-0.589 so I would input:

duration = pulseIn(echoPin, HIGH);

delay (1000);

distance=0.007*duration-0.589;

Serial.println(distance);

delay(500);

## Recommendations

• ### Arduino Class

69,072 Enrolled

• ### Make it Move Contest

We have a be nice policy.