Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Arnov Sharma
Published © CC BY

Ultrasonic Sensor with LCD I2C

Displaying distance measured by ultrasonic sensor on liquid crystal display with I2C.

BeginnerFull instructions provided81,768
Ultrasonic Sensor with LCD I2C

Things used in this project

Story

Read more

Schematics

fritzing-sketch-for-lcd1602-and-arduino_JP81Pzz7yc.jpg

connect echo and tric pin according to the sketch

Code

Code

C/C++
#include<UltraDistSensor.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,20,4);

UltraDistSensor mysensor;
float reading;

void setup() {
    lcd.init();                      // initialize the lcd 
    lcd.backlight();
    Serial.begin(9600);
    mysensor.attach(12,13);//Trigger pin , Echo pin
}

void loop() {
    reading=mysensor.distanceInCm();
     lcd.setCursor(0,0);
     lcd.print("Distance :- ");
      lcd.print(reading);

    delay(1000);
}

Credits

Arnov Sharma
329 projects • 334 followers
Just your average MAKER
Contact

Comments

Please log in or sign up to comment.