Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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