Advertisement
Guest User

Arduino Thermometer (LM35 + LCD)

a guest
Sep 29th, 2017
7,415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.51 KB | None | 0 0
  1. #include <LiquidCrystal.h>        
  2. LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
  3.  
  4. int value;
  5. float celsius;
  6. const int lmPin = 0; // The analog pin of the LM35
  7.                  
  8. void setup() {
  9.   lcd.begin(16,2);
  10. }
  11. void loop() {
  12.   value = analogRead(inPin);
  13.   celsius = (value / 1023) * 500; // Getting the temperature from the sensor
  14.  
  15.   lcd.clear();
  16.   lcd.setCursor(0,0);
  17.   lcd.print(celsius);
  18.   lcd.print("C");
  19.   lcd.setCursor(0,1);
  20.   lcd.print((celsius * 9)/5 + 32);
  21.   lcd.print("F");
  22.   delay(1000);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement