Project tutorial
Digital Meter

Digital Meter © GPL3+

Measuring short distances digitally as simple as possible with the SRF05 ultrasonic sensor.

  • 996 views
  • 2 comments
  • 3 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)

Apps and online services

About this project

Let's Measure short distances simply

With this project measuring a short distance (less than 5 meters) is possible by just putting the device at the starting point and then the device measures distance between itself (the start point) and first object that is in its way.

How it works

The main module of this system is an SRF05 (ultrasonic module), this module measures less than 5 meters distances, then measuring distance is shown on an LCD in cm and inch.

System's Working

More Details

This device works in two modes:

  • Scanning Mode: Measure distance every one minutes and shows them on LCD.
  • Capturing Mode: Measure distance by pressing a button and then the device displays the distance measured on the LCD for three seconds.

Hint: First mode is better when you are measuring in none-static environment, and second mode is best when you want to measure in case that you can't read the result at the moment.

Code

digital meter codeArduino
//by t.vajed

#include <LiquidCrystal.h>
int echoPin=5;
int pingPin=6;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.clear();
  delay(150);
  lcd.print("digital, meter");
  delay(2500);
  lcd.clear();
  delay(150);
  pinMode(pingPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(A0,INPUT_PULLUP);
  pinMode(A1,INPUT_PULLUP);
}

void loop() {
//srf05 works in two mode in this project, first capture
   while(digitalRead(A0)==0){
    lcd.clear();
    lcd.print("capture mode");
    delay(200);
    if(digitalRead(A1)==0){
     //srf starts working 
     digitalWrite(pingPin, 0);
     delayMicroseconds(5);
     digitalWrite(pingPin, 1);
     delayMicroseconds(5);
     digitalWrite(pingPin, 0);
     int duration=pulseIn(echoPin, HIGH);
     lcd.clear();
     lcd.print(duration/58);
     lcd.print(" cm");
     lcd.setCursor(0,1);
     lcd.print(duration/74/2);
     lcd.print(" in");
     delay(3500);
    }
  }
  //scanning mode of srf
   digitalWrite(pingPin, 0);
   delayMicroseconds(5);
   digitalWrite(pingPin, 1);
   delayMicroseconds(5);
   digitalWrite(pingPin, 0);
   int duration=pulseIn(echoPin, HIGH);
   lcd.print(duration/58);
   lcd.print(" cm");
   lcd.setCursor(0,1);
   lcd.print(duration/74/2);
   lcd.print(" in");
   delay(1000);
   lcd.clear();
}

Custom parts and enclosures

digital meter pcb
Dig%20meter pcb

Schematics

digital meter bread board
Dig%20meter bb

Comments

Similar projects you might like

Simple Arduino Digital Clock Without RTC

Project in progress by Annlee Fores

  • 96,159 views
  • 23 comments
  • 80 respects

Arduino-based Digital Scale with HX711 and VFD Display

Project showcase by antiElectron

  • 5,370 views
  • 0 comments
  • 22 respects

Stereo NeoPixel Ring VU Meter

Project showcase by ericBcreator

  • 29,176 views
  • 268 comments
  • 70 respects

Christmas Tree with 150 Digital LED Pixels

Project tutorial by Martino Ghisleni

  • 4,030 views
  • 0 comments
  • 9 respects

Network VU Sound Level Meter using C#, Arduino and ESP8266

Project tutorial by Fanatic Series

  • 568 views
  • 0 comments
  • 3 respects
Add projectSign up / Login