// Temperature Conversation program
// 0 on input corresponds to 10C
//1023 on input corresponds to 50C
// Range is therefore 40C
// Assume linear response from sensor so relationship is of the form Y=MX+Conversation
// Temp = M*input +Conversation
// C = 10
// M = delta y / delta x = 40/1023 = 0.039
// So Temp(C) = 0.039*input + 10
// note we need float variables to perform the calculations.
// input is an int so we need to cast it to a float
int readVal;
float reading;
float slope = -.124105;
float Celsius;
float y_intercept = 94.272076;
void setup()
{
Serial.begin(9600);
}
void loop()
{
readVal = analogRead(A5);
reading = float(readVal);
Celsius = (reading*slope) + y_intercept;
Serial.print(readVal);
Serial.print(" ");
Serial.println(Celsius);
delay ( 500);
}