#include <LiquidCrystal_I2C.h>
#include <Wire.h>
LiquidCrystal_I2C lcd (0x27,16,2);
int trigPin=2;
int echoPin=3;
int jarak;
void setup() {
pinMode (trigPin,OUTPUT);
pinMode(echoPin,INPUT);
Serial.begin(9600);
lcd.begin(16,2);
lcd.init();
lcd.backlight();
lcd.setCursor(1,1);
lcd.print("sensor Utrasonik");
delay(2000);
lcd.clear();
}
void loop() {
digitalWrite(trigPin,LOW);
delayMicroseconds(2);
digitalWrite(trigPin,HIGH);
delayMicroseconds(10);
digitalWrite(trigPin,LOW);
int durasi=pulseIn(echoPin,HIGH);
int jarak=durasi*0.034/2;
lcd.setCursor(1,0);
lcd.print(jarak);
lcd.print("cm");
}