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,915
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
341 projects • 349 followers
I'm Arnov. I build, design, and experiment with tech—3D printing, PCB design, and retro consoles are my jam.
Contact

Comments

Please log in or sign up to comment.