#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Inisialisasi objek LCD I2C dengan alamat 0x27 (alamat bisa berbeda)
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int sensor = A1;
int tempc;
float tempf;
float vout;
float adc;
void setup()
{
// Inisialisasi LCD
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Shinta Kurnia A.");
lcd.setCursor(0, 1);
lcd.print("EK-2B / 17");
delay(2000);// Delay atau tunggu 2 detik
lcd.clear();
pinMode(sensor, INPUT);
}
void loop()
{
adc = analogRead(sensor);
vout = adc / 1023 * 5;
tempc = vout * 100;
tempf = (tempc * 1.8) + 32;
// Menampilkan hasil ke LCD
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Suhu = ");
lcd.print(tempc);
lcd.print(" C");
lcd.setCursor(0, 1);
lcd.print("Suhu = ");
lcd.print(tempf);
lcd.print(" F");
delay(500);
}