ChristineWu

Temperature LCD

Jan 26th, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1.  
  2. #include <LiquidCrystal.h>
  3. //initialize the library with the numbers of the interface pins
  4. LiquidCrystal lcd(2,3,4,5,6,7);
  5.  
  6. const int TempPin=A0;
  7. int tempVal=0;
  8.  
  9. void setup()
  10. {
  11. // put your setup code here, to run once:
  12. //set up the number of columns and rows on the LCD
  13. lcd.begin (16,2);
  14. lcd.setCursor (1,0); //3 is the 4th column, 0 is the first row)
  15. lcd.print ("The temperature");
  16. //set the cursor to column 0, line 1
  17. //line 1 is the second row, since counting begins with 0
  18. lcd.setCursor(2,1);
  19. //pring to the second line
  20. lcd.print("right now is");
  21. Serial.begin(9600);
  22.  
  23. }
  24.  
  25. void loop()
  26. {
  27. delay (3000);
  28. tempVal=analogRead (TempPin);
  29. tempVal=map (tempVal,850,970,50,90);
  30. Serial.println (tempVal);
  31. lcd.clear();
  32. lcd.setCursor (5,1); //because the column changes but row is the same
  33. lcd.print(tempVal);
  34.  
  35. }
Add Comment
Please, Sign In to add comment