Created
March 1, 2015 13:19
-
-
Save lupettohf/6e5e033bf66901870b02 to your computer and use it in GitHub Desktop.
Arduino Thermometer using a 16x2 LCD and a LM35 sensor.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TermometroLCD2.ino | |
#include <LiquidCrystal.h> | |
#include <EEPROM.h> | |
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); | |
int temperatura = 0; | |
int tempmax; | |
int tempmin; | |
int voltage; | |
void setup() { | |
lcd.begin(16, 2); | |
} | |
void scriviEEPROM(int i, boolean minimo){ | |
if(minimo){ | |
EEPROM.write(0, i); | |
}else{ | |
EEPROM.write(1, i); | |
} | |
} | |
void leggiEEPROM(){ | |
tempmin = EEPROM.read(0); | |
tempmax = EEPROM.read(1); | |
} | |
void loop() { | |
voltage = analogRead(0); | |
temperatura = voltage/9.8; | |
if(temperatura > tempmax){ | |
scriviEEPROM(temperatura, false); | |
} | |
if(temperatura < tempmin){ | |
scriviEEPROM(temperatura, true); | |
} | |
if(tempmin = 0){ | |
tempmin = temperatura; | |
} | |
leggiEEPROM(); | |
lcd.print(“Live:”); | |
lcd.print(temperatura); | |
lcd.write(B11011111); | |
lcd.setCursor(0,1); | |
lcd.print(“Min:”); | |
lcd.print(tempmin); | |
lcd.write(B11011111); | |
lcd.setCursor(9,1); | |
lcd.print(“Max:”); | |
lcd.print(tempmax); | |
lcd.write(B11011111); | |
delay(2000); | |
lcd.clear(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment