View difference between Paste ID: RzwzNQtZ and 4CGdNAjy
SHOW: | | - or go back to the newest paste.
1
float voltage = 0;                          //the voltage measured from the TMP36
2
float degreesC = 0;                         //the temperature in Celsius, calculated from the voltage
3
float degreesF = 0;                         //the temperature in Fahrenheit, calculated from the voltage
4
5
void setup() {
6
7
  Serial.begin(9600);
8
9
}
10
11
void loop() {
12
13
  voltage = analogRead(A0) * 0.004882814;   //convert the analog reading, which varies from 0 to 1023, back to a voltage value from 0-5 volts
14
  degreesC = (voltage - 0.5) * 100.0;       //convert the voltage to a temperature in degrees Celsius
15
  degreesF = degreesC * (9.0/5.0) + 32.0;   //convert the voltage to a temperature in degrees Fahrenheit
16
17
 
18
  Serial.println(degreesF);
19
  delay(1000);
20
  
21
}