const int trigpin = 12;
const int echopin =11;
//YWROBOT
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
//string (khusus huruf), int (bilangan bulat), float (desimal)
String feli = "makan";
int bilqis = 13;
float aina = 13.5;
void setup()
{
lcd.init(); // initialize the lcd
// Print a message to the LCD.
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("imoets");
lcd.setCursor(2,1);
lcd.print(bilqis);
digitalWrite(trigpin, LOW);
digitalWrite(echopin, LOW);
pinMode(trigpin, OUTPUT);
pinMode(echopin, INPUT);
}
void loop()
{
digitalWrite(trigpin, HIGH);
delayMicroseconds(10);
digitalWrite(trigpin, LOW);
long duration = pulseIn(echopin, HIGH);
long distance = duration/58.0;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("jarak : ");
lcd.print(distance);
lcd.print("cm");
delay(1000);
}