user2780027
Published © GPL3+

Distance Measurer using Ultrasonic and LCD

This circuit uses an ultrasonic sensor to measure distance and displays it on a liquid crystal display.

BeginnerShowcase (no instructions)6 minutes933
Distance Measurer using Ultrasonic and LCD

Things used in this project

Hardware components

ultrasonic sensor
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

lcd-to-arduino-interface_CYoYY7jV3s.jpg

Code

Arduino code

C/C++
Upload this to your arduino UNO.
// include the library codes:
#include <LiquidCrystal.h>
#include <Ultrasonic.h>

// initialize the library with the numbers of the interface pins for both ultrasonic and LCD
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
Ultrasonic ultrasonic(2, 4);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
 

}

void loop() {

 lcd.clear();
  lcd.print("Centimeters:");             //display the 
  lcd.print(ultrasonic.distanceRead());  //amount of centimeters
  lcd.setCursor(0, 1);         //set the cursor to the bottom line
  lcd.print("Meters:");                       //display the amount of
  lcd.print(ultrasonic.distanceRead() / 100); //meters
  delay(1000);
  
}

Credits

user2780027

user2780027

1 project • 1 follower

Comments