Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //LM35 output voltage has a linear relation with the Celsius temperature, output of 0 v when 0 ℃,
- //every increase 1 ℃, the output voltage increase 10 mv
- #define lmPin A0 //LM35 attach to
- #include <LiquidCrystal.h>
- // initialize the library with the numbers of the interface pins
- LiquidCrystal lcd(4, 6, 10, 11, 12, 13);
- float tem = 0;
- long lmVal = 0;
- void setup()
- {
- lcd.begin(16, 2); // set up the LCD's number of columns and rows:
- }
- void loop()
- {
- lmVal = analogRead(lmPin);
- tem = (lmVal * 0.0048828125 * 100);//5/1024=0.0048828125;1000/10=100
- lcd.setCursor(5,0);
- lcd.print("LM35");
- lcd.setCursor(0,1);
- lcd.print("Tem= ");
- lcd.setCursor(5,1);
- lcd.print(tem);
- lcd.print(" C");
- delay(200);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement