#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); 
int trigPin = 9; 
int ledpin =12;
int echoPin = 8; 
float duration_us, distance_cm;

void setup() {
  lcd.init(); 
  lcd.backlight(); 
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT); 
}

void loop() {
  
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  
  duration_us = pulseIn(echoPin, HIGH);

  
  distance_cm = 0.017 * duration_us;

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Distance: ");
  lcd.print(distance_cm);

  if (distance_cm == 150 ){
    digitalWrite(led1, HIGH);
    digitalWrite(led2,LOW);
    
  }

  //digitalWrite(ledpin, HIGH);


  delay(500);

  //digitalWrite(ledpin, LOW);
}