#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define PIN_TRIG 3
#define PIN_ECHO 2
LiquidCrystal_I2C lcd(0x27, 16, 2); // Set the LCD I2C address to 0x27 for a 16x2 display
void setup() {
Serial.begin(115200);
lcd.begin(16, 2);
pinMode(PIN_TRIG, OUTPUT);
pinMode(PIN_ECHO, INPUT);
//lcd.setCursor()
}
void loop() {
lcd.clear();
digitalWrite(PIN_TRIG, HIGH);
delayMicroseconds(10);
digitalWrite(PIN_TRIG, LOW);
// Read the result:
int duration = pulseIn(PIN_ECHO, HIGH);
lcd.setCursor(1, 1);
lcd.print(duration / 58);
delay(2000);
}