#include <LiquidCrystal.h>
#include <math.h>
// RS=12, E=11, DB4=5, DB5=4, DB6=3, DB7=2
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("Datchik NTC");
lcd.setCursor(0, 1);
lcd.print("Zagruzka...");
delay(2000);
lcd.clear();
}
void loop() {
int raw = analogRead(A0);
// Termistor PASTDA (GND tomonda) bo'lsa:
float resistance = 10000.0 * raw / (1023.0 - raw);
// Steinhart-Hart formulasi
float tempK = 1.0 / (log(resistance / 10000.0) / 3950.0 + 1.0 / 298.15);
float tempC = tempK - 273.15;
// Satr 1: Kelvin
lcd.setCursor(0, 0);
lcd.print("Tk=");
lcd.print(tempK, 1);
lcd.print(" K ");
// Satr 2: Celsius
lcd.setCursor(0, 1);
lcd.print("Tc=");
lcd.print(tempC, 1);
lcd.print((char)223);
lcd.print("C ");
delay(1000);
}