#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal_I2C.h>

const int pinData = 2;

OneWire oneWire(pinData);
DallasTemperature sensors(&oneWire);

LiquidCrystal_I2C lcd(0x27, 16, 2); 
const int potPin = A0;

void setup() {
  Serial.begin(9600);
  lcd.begin(16, 2); 
  lcd.print("Suhu: ");
  sensors.begin();
}

void loop() {
  float temperature = readTemperature();

  lcd.setCursor(7, 0); 
  lcd.print("       "); 
  lcd.setCursor(7, 0);
  lcd.print(temperature);
  lcd.print(" C");

  Serial.print("Suhu: ");
  Serial.print(temperature);
  Serial.println("°C");
  
  delay(1000);
}

float readTemperature() {
  int potValue = analogRead(potPin);
  float temperature = map(potValue, 0, 1023, 0, 100); 
  return temperature;
}