-
1Run a Program
#include
#include "LiquidCrystal.h"
LiquidCrystal lcd(44,46,40,52,50,48);
float A = 1.009249522e-03, B = 2.378405444e-04, C = 2.019202697e-07;
float T,logRt,Tf,Tc;
float Thermistor(int Vo) {
logRt = log(10000.0*((1024.0/Vo-1)));
T = (1.0 / (A + B*logRt + C*logRt*logRt*logRt)); // We get the temperature value in Kelvin from this Stein-Hart equation
Tc = T - 273.15; // Convert Kelvin to Celcius
Tf = (Tc * 1.8) + 32.0; // Convert Kelvin to Fahrenheit
return T;
}void setup(){
lcd.begin(16,2);
lcd.clear();
}void loop()
{
lcd.setCursor(0,0);
lcd.print("Temp:");
lcd.print((Thermistor(analogRead(0))));
lcd.print("k ");
lcd.setCursor(0,1);
lcd.print((Tc));
lcd.print(" C ;");lcd.setCursor(9,1);
lcd.print((Tf));
lcd.print(" F");
delay(800);
}
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.