Advertisement
Braulio777

Arduino Thermometer

Jun 16th, 2015
542
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. //Reading Temperature with LM35 Sensor
  2. //Measuring in both scales Celsius and Fahrenheit
  3. //Arduino Thermometer Shield
  4. #include <LiquidCrystal.h>
  5. LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
  6. float tempC;
  7. float tempF;
  8. int tempPin = 1;
  9. void setup(){
  10.   lcd.begin(16, 2);
  11.   lcd.print("Csius=");
  12.   lcd.setCursor(0, 1);
  13.   lcd.print("Fheit=");
  14. }
  15. void loop(){
  16.   tempC = analogRead(tempPin);          
  17.   tempC = (5.0 * tempC * 100.0)/1024.0;  
  18.   tempF = ((tempC*9)/5) + 32;            
  19.  
  20.   lcd.setCursor(6, 0);
  21.   lcd.print(tempC,1);
  22.   lcd.print("'C");
  23.  
  24.   lcd.setCursor(6, 1);
  25.   lcd.print(tempF,1);
  26.   lcd.print("'F");
  27.   delay(1000);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement