#include <LiquidCrystal_I2C.h>
#define I2C_ADDR    0x27
#define LCD_COLUMNS 16
#define LCD_LINES   2
String tempc,humidity;
LiquidCrystal_I2C lcd(I2C_ADDR, LCD_COLUMNS, LCD_LINES);
#define PIN_TRIG 4
#define PIN_ECHO 2
float duration, CM, Inches;
void setup() {
  Serial.begin(115200);
  lcd.init();
  lcd.backlight();
  pinMode(PIN_TRIG, OUTPUT);
  pinMode(PIN_ECHO, INPUT);
}
void loop() {
  // Start a new measuremwnt:
  digitalWrite(PIN_TRIG, HIGH);
  delayMicroseconds(10);
  digitalWrite(PIN_TRIG, LOW);
  // Read the reult:
  duration = pulseIn(PIN_ECHO, HIGH);
  CM=duration / 58.8;
  Inches=duration / 148;
  Serial.print("Distance in CM:");
  Serial.println(CM);
  Serial.print("Distance in inches:");
  Serial.println(Inches);
  lcd.setCursor(0, 0);
  lcd.print("Inches");
  lcd.setCursor(11, 0);
  lcd.print("CM");
  lcd.setCursor(1, 1);
  lcd.print(Inches,2);
  lcd.setCursor(10, 1);
  lcd.print(CM, 2);
  lcd.setCursor(14, 1);
  delay(2000);
  lcd.clear();
  delay(500);
}