#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
float ADCReads[6] = { 100, 278, 400, 500, 880, 710 };
float TheVoltageValue = 0.0, Slope = 0.00625, Displacement = 0.424;
int TheCelsiusValue = 0;
const float MyReferenceVoltage = 1.1;
void setup()
{
// Serial.begin(115200);
lcd.begin(16, 2);
}
void loop()
{
for (int i = 0; i < 6; i++)
{
lcd.setCursor(0, 0);
lcd.print("ADC= ");
lcd.print(ADCReads[i], 0);
lcd.print(" mV=");
TheVoltageValue = VoltageFormula(ADCReads[i]);
lcd.print(TheVoltageValue);
lcd.setCursor(0, 1);
lcd.print((char)223);
lcd.print("C= ");
TheCelsiusValue = X_axisFormula(ADCReads[i]);
lcd.print(TheCelsiusValue);
delay(500);
// lcd.clear();
}
}
int X_axisFormula(float Value)
{
return (Value - Displacement) / Slope;
}
float VoltageFormula(float Value)
{
float temp = Value * (MyReferenceVoltage / (pow(2, 10) - 1));
return temp * 1000;
// 0.0048875855
// return Value * (0.0048);
}