loading

This meter was developed using Arduino Uno, HC-SR04 sensor and a 16X2 LCD display for displaying each measurement.

Step 1: Bill of Materials

1 Arduino Uno

1 HC-SR04 ultrasonic sensor

1 16x2 LCD Display

1 Arduino Uno Proto Shield

1 Headers

1 10k Ohm Square Cermet Potentiometer

1 USB 2.0 Cable

1 Enclosure for Arduino Boards

Step 2: Schematic

This is your diagram so that you follow step by step the project in its essence.

Step 3: Assembling the Project

I installed the 16X2 LCD display into the Arduino PCB using the headers and also installed the HC-SR04 sensor. I used red and black heat shrink tube for connecting to +5V and GND respectively in this sensor while connecting trigPin to arduino pin 12 and echoPin to Arduino pin 13 for completing this operation.

Step 4: Joining the Parts

Mount what you completed in the previous step on your Arduino Uno.

Step 5: Upload the Code

//Code

#include <LiquidCrystal.h>

LiquidCrystal lcd(11, 9, 5, 4, 3, 2);

#define trigPin 12

#define echoPin 13

int duration, Distance;

void setup() {

Serial.begin(9600);

pinMode(trigPin,OUTPUT);

pinMode(echoPin,INPUT);

lcd.begin(16,2);

lcd.setCursor(0,0);

lcd.print( "Distance:" );

}

void loop() {

digitalWrite(trigPin, HIGH);

delayMicroseconds(1000);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

Distance = (duration/2) / 29.1;

Serial.print(Distance);

Serial.println(" cm");

lcd.setCursor(0,1);

lcd.print(" ");

lcd.setCursor(0,1);

lcd.print(Distance);

lcd.print(" cm");

delay(500);

}

Step 6: Code Uploaded

For uploading the code, you should copy and paste the code in the previous step.

Step 7: Enjoy Your Project

Enjoy your project by measuring distances with this amazing meter.

Hi<br>
How accurate is it?
<p><a href="https://www.sparkfun.com/products/13959">https://www.sparkfun.com/products/13959</a></p><p>Description: This is the HC-SR04 ultrasonic ranging sensor. This economical sensor provides 2cm to 400cm of non-contact measurement functionality with a ranging accuracy that can reach up to 3mm. Each HC-SR04 module includes an ultrasonic transmitter, a receiver and a control circuit.</p>
<p>For responding your question, here is the following code:</p><p>#include &lt;LiquidCrystal.h&gt;</p><p>LiquidCrystal lcd(11, 9, 5, 4, 3, 2);</p><p>#define trigPin 12</p><p>#define echoPin 13</p><p>double duration, Distance;</p><p>void setup() </p><p>{</p><p>Serial.begin(9600);</p><p>pinMode(trigPin,OUTPUT);</p><p>pinMode(echoPin,INPUT);</p><p>lcd.begin(16,2);</p><p>}</p><p>void loop() </p><p>{</p><p>digitalWrite(trigPin, HIGH);</p><p>delayMicroseconds(2000);</p><p>digitalWrite(trigPin, LOW);</p><p>duration = pulseIn(echoPin, HIGH);</p><p>Distance = (duration/2) / 29.1;</p><p>Serial.print(Distance);</p><p>Serial.println(&quot; cm&quot;);</p><p>lcd.setCursor(0,0);</p><p>lcd.print( &quot;Distance = &quot; );</p><p>lcd.setCursor(0,1);</p><p>lcd.print(&quot; &quot;);</p><p>lcd.setCursor(0,1);</p><p>lcd.print(Distance,3);</p><p>lcd.print(&quot; cm &quot;);</p><p>delay(250);</p><p>}</p>
<p>Hi braulio777,</p><p>I'm very interested in working on this project, however since I am still new to arduino I would like to ask whether it is possible to make the reading of the sensor more accurate i.e. displaying 12.52 cm and what is the maximum effective range of the sensor?</p>
<p>You can upload the following code:</p><p>//Code</p><p>#include &lt;LiquidCrystal.h&gt;</p><p>LiquidCrystal lcd(11, 9, 5, 4, 3, 2);</p><p>#define trigPin 12</p><p>#define echoPin 13</p><p>double duration, Distance;</p><p>void setup() </p><p>{</p><p>Serial.begin(9600);</p><p>pinMode(trigPin,OUTPUT);</p><p>pinMode(echoPin,INPUT);</p><p>lcd.begin(16,2);</p><p>}</p><p>void loop() </p><p>{</p><p>digitalWrite(trigPin, HIGH);</p><p>delayMicroseconds(2000);</p><p>digitalWrite(trigPin, LOW);</p><p>duration = pulseIn(echoPin, HIGH);</p><p>Distance = (duration/2) / 29.1;</p><p>Serial.print(Distance);</p><p>Serial.println(&quot; cm&quot;);</p><p>lcd.setCursor(0,0);</p><p>lcd.print( &quot;Distance = &quot; );</p><p>lcd.setCursor(0,1);</p><p>lcd.print(&quot; &quot;);</p><p>lcd.setCursor(0,1);</p><p>lcd.print(Distance,3);</p><p>lcd.print(&quot; cm &quot;);</p><p>delay(250);</p><p>} </p>
will this code work for the mini pro?
<p>I think so.</p>

About This Instructable

3,167views

77favorites

License:

More by braulio777:4-Digit Yellow Binary Counter 2-Digit Green Binary Counter Green Binary Counter 
Add instructable to: