Make a Distance Meter

by yobots in Circuits > Arduino

3099 Views, 17 Favorites, 0 Comments

Make a Distance Meter

Distance Meter_new_blog.jpg
Distance Meter_new.jpg

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

How to Make Distance Meter

Material Required

Screenshot (425).png

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

Make the Circuit Board

Screenshot (426).png
Screenshot (430).png
Screenshot (428).png
Screenshot (429).png
Screenshot (431).png
Screenshot (432).png
Screenshot (433).png

Make the circuit board as per this circuit diagram.

Arduino Code

Screenshot (441).png

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);*/

}

Downloads

Cut the Edge of Plastic Box

Screenshot (444).png
Screenshot (445).png
Screenshot (446).png
Screenshot (447).png

Cut all the extra edges of your plastic box.

Make Some Hole

Screenshot (455).png
Screenshot (452).png
Screenshot (451).png
Screenshot (456).png
Screenshot (454).png
Screenshot (457).png
Screenshot (460).png
Screenshot (458).png
Screenshot (459).png

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.

Download the Scale

scalE1.jpg
Screenshot (463).png
Screenshot (464).png

Download this image for scaling.

Make a Arrow and Fix Servo

Screenshot (465).png
Screenshot (466).png
Screenshot (462).png

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

Assemble

Screenshot (467).png
Screenshot (468).png
Screenshot (469).png
Screenshot (470).png
Screenshot (471).png
Screenshot (423).png

Like and Subscribe

If you like this instructable.

Please like it and also subscribe my youtube

www.youtube.com/c/yobots