#include <NewPing.h>
#include <LiquidCrystal_I2C.h>

NewPing cekJarak(10,11,200); //object(pinTrig,pinEcho,jarak_maks)
const int col = 16;
const int row = 2;
LiquidCrystal_I2C lcd(0x27, col, row); //lcd(address modul2c, banyak kolom, banyak baris)

int jarak;
int lamaDelay;

const int pinled = 13;
const int pinbuzz = 12;
int pos_cursor = 0;
String status="";

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(pinled,OUTPUT);
  pinMode(pinbuzz,OUTPUT);
  lcd.init();
  lcd.backlight();
  lcd.clear();
  // lcd.setCursor(0,0);  //(col, row)
  // lcd.print("Alpadangy");
  // lcd.setCursor(0,1);  //(col, row)
  // lcd.print("Marhaban uda hendri");
}

void loop() {
  // put your main code here, to run repeatedly:
jarak = cekJarak.ping_cm(); //Mengambil data jarak yang dihitung sensor dalam cm
Serial.print(jarak);
Serial.println(" cm");

lamaDelay = jarak*25;
if(jarak > 15){
  status = "Aman";
}else{
  status = "Bahaya!";
}

digitalWrite(pinled,HIGH);
delay(lamaDelay);
digitalWrite(pinled,LOW);
delay(lamaDelay);

digitalWrite(pinbuzz, HIGH);
delay(lamaDelay);
digitalWrite(pinbuzz, LOW);
delay(lamaDelay);

lcd.clear();
lcd.setCursor(pos_cursor,0);  //(col, row)
lcd.print("Jarak (cm):");
lcd.setCursor(pos_cursor+12,0);  //(col, row)
lcd.print(jarak);
lcd.setCursor(pos_cursor,1);  //(col, row)
lcd.print("Status :");
lcd.setCursor(pos_cursor+9,1);  //(col, row)
lcd.print(status);
}

$abcdeabcde151015202530fghijfghij