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