Advertisement
Guest User

Untitled

a guest
May 29th, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. //LM35 output voltage has a linear relation with the Celsius temperature, output of 0 v when 0 ℃,
  2. //every increase 1 ℃, the output voltage increase 10 mv
  3. #define lmPin A0 //LM35 attach to
  4. #include <LiquidCrystal.h>
  5. // initialize the library with the numbers of the interface pins
  6. LiquidCrystal lcd(4, 6, 10, 11, 12, 13);
  7.  
  8. float tem = 0;
  9. long lmVal = 0;
  10.  
  11. void setup()
  12. {
  13. lcd.begin(16, 2); // set up the LCD's number of columns and rows:
  14. }
  15. void loop()
  16. {
  17. lmVal = analogRead(lmPin);
  18. tem = (lmVal * 0.0048828125 * 100);//5/1024=0.0048828125;1000/10=100
  19. lcd.setCursor(5,0);
  20. lcd.print("LM35");
  21. lcd.setCursor(0,1);
  22. lcd.print("Tem= ");
  23. lcd.setCursor(5,1);
  24. lcd.print(tem);
  25. lcd.print(" C");
  26. delay(200);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement