Introduction: Make a Distance Meter

About: Make your own things........

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

Step 1: How to Make Distance Meter

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

8. Header Pins

9. Wire

Step 3: Make the Circuit Board

Make the circuit board as per this circuit diagram.

Step 4: Arduino Code

Download the code from the link

#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 7: Download the Scale

Download this image for scaling.

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 9: Assemble

Step 10: Like and Subscribe

If you like this instructable.

Please like it and also subscribe my youtube

www.youtube.com/c/yobots