Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2019
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1.  
  2. float voltage = 0; //the voltage measured from the TMP36
  3. float degreesC = 0; //the temperature in Celsius, calculated from the voltage
  4. float degreesF = 0; //the temperature in Fahrenheit, calculated from the voltage
  5.  
  6. void setup() {
  7.  
  8. Serial.begin(9600);
  9.  
  10. }
  11.  
  12. void loop() {
  13.  
  14. voltage = analogRead(A0) * 0.004882814; //convert the analog reading, which varies from 0 to 1023, back to a voltage value from 0-5 volts
  15. degreesC = (voltage - 0.5) * 100.0; //convert the voltage to a temperature in degrees Celsius
  16. degreesF = degreesC * (9.0/5.0) + 32.0; //convert the voltage to a temperature in degrees Fahrenheit
  17.  
  18.  
  19. Serial.println(degreesF);
  20. delay(1000);
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement