Use the Arduino to read the value of the LM35 temperature sensor to calculate the current temperature displayed on the LCD:
About the display of the control LCD the http://www.cnblogs.com/Zhang-Shangyu/p/5249206.html has been introduced in the previous article, here is a description of the LM35 temperature sensor
LM35 chip Real-picture
From http://www.arduino.cn/thread-1055-1-1.html
Hardware connection:
LCD Connection method Previous article http://www.cnblogs.com/Zhang-Shangyu/p/5249206.html
LM35 connection: VCC pin 5v,gnd foot panel bag gnd,vout pin connect Arduino analog signal foot A0
Do not connect the LM35 VCC foot and GND pin in the operation, from the flat side of the chip, the leftmost foot is VCC and the rightmost foot is GND.
Software code:
#include <LiquidCrystal.h>intTmp=0;//Analog Foot A0intdata;intCelsius; Liquidcrystal LCD (12,11,5,4,3,2);//LCD Construction FunctionvoidSetup () {Lcd.begin (16,2); Lcd.print ("The temperature"); Lcd.setcursor (3,1); Lcd.print ("Is"); }voidLoop () {Lcd.setcursor (6,1); Data= Analogread (TMP);//get the value of the temperature sensorCelsius= (125*data) >>8;//formula for calculating temperatureLcd.print (Celsius); Lcd.print ((Char) 223); Lcd.print (C); Delay (2000);//refresh after two seconds}
Run:
It seems to be a success, but the temperature show will have a 1-2-degree jump change.
Arduino LM35 Thermometer