edge lab LIVE! starts Tuesday in Munich. Grab a workshop seat and take home the board you build on. Code FRIEND-HACKSTER saves 20%. () Learn more!
Arnov Sharma
Published © CC BY

Ultrasonic Sensor with LCD I2C

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

BeginnerFull instructions provided82,374
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
403 projects • 445 followers
I'm Arnov. I build, design, and experiment with tech; 3D printing, PCB design, and retro consoles are my jam.

Comments