# Make a Distance Meter

1,994

16

1

## Introduction: Make a Distance Meter

In this instructable, I have shown How to make Distance meter with Ultrasonic Sensor and Arduino nano.

### 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 2: Material Required

1. Plastic Box

2. Arduino Nano

3. Ultrasonic Sensor (HC-SR04)

4. Servo Motor

5. Vero Board

6. Battery

7. Switch

9. Wire

## Step 3: Make the Circuit Board

Make the circuit board as per this circuit diagram.

## Step 4: Arduino Code

#define echoPin 6
#define trigPin 7

#include Servo myservo;

void setup()

{

Serial.begin(9600);

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

myservo.attach(9);

myservo.write(180);

}

void loop()

{

float distance, duration;

digitalWrite(trigPin , HIGH);

delayMicroseconds(100);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance= (((duration/2)/29.1/100)*39.37);

int angle = map( distance, 0,12,180,0);

myservo.write(angle);

/*Serial.print("Distance is"); /////////////////////////////////////////////////////

Serial.print(distance); //////Use this section to check///////

Serial.println("in"); //////every thing is ok//////////////////////

Serial.flush(); ///////////////////////////////////////////////////////

delay(1000);*/

}

## Step 5: Cut the Edge of Plastic Box

Cut all the extra edges of your plastic box.

## Step 6: Make Some Hole

Make some hole as per your circuit board dimension for your switch, charging port and also for ultrasonic sensor.

And also make some hole on the circuit board for fixing the board with plastic box.

## Step 8: Make a Arrow and Fix Servo

Make an arrow with the cardboard. And fix the servo with glue on the plastic box's front case.

## Step 10: Like and Subscribe

If you like this instructable.

183 16K
250 33K
124 12K