Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float voltage = 0; //the voltage measured from the TMP36
- float degreesC = 0; //the temperature in Celsius, calculated from the voltage
- float degreesF = 0; //the temperature in Fahrenheit, calculated from the voltage
- void setup() {
- Serial.begin(9600);
- }
- void loop() {
- voltage = analogRead(A0) * 0.004882814; //convert the analog reading, which varies from 0 to 1023, back to a voltage value from 0-5 volts
- degreesC = (voltage - 0.5) * 100.0; //convert the voltage to a temperature in degrees Celsius
- degreesF = degreesC * (9.0/5.0) + 32.0; //convert the voltage to a temperature in degrees Fahrenheit
- Serial.println(degreesF);
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement