/* Program 7-2 Read the analog value of the pin connected to the temperature sensor. * The temperature sensor on is connected to pin A2. * The temperature sensor is an LM45, The value is scaled to degree F * then sent to the Serial monitor. */ const int temp = A2; void setup() { Serial.begin(9600); Serial.println("Temperature sensor:"); } void loop() { /* read the voltage from ADC */ int tempValue = analogRead(temp); /* write it to the Serial monitor */ Serial.print(" Temperature = "); Serial.print(tempValue); Serial.print(", "); float degreeC = (float)tempValue / 1023 * 5 / 0.01; Serial.print(degreeC, 2); Serial.print(" C, "); float degreeF = degreeC * 9.0 / 5.0 + 32; Serial.print(degreeF, 2); Serial.println(" F"); }