Skip to content

Instantly share code, notes, and snippets.

@lupettohf
Created March 1, 2015 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lupettohf/6e5e033bf66901870b02 to your computer and use it in GitHub Desktop.
Save lupettohf/6e5e033bf66901870b02 to your computer and use it in GitHub Desktop.
Arduino Thermometer using a 16x2 LCD and a LM35 sensor.
// 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