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,428
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

Arnov Sharma

303 projects • 305 followers
Just your average MAKER

Comments