/*
*/
#include <Wire.h>
#include <RTClib.h>
#include <LiquidCrystal.h>
#define BACKLIGHT 22
#define CONTRAST 23
#define SET 10
#define PIU 9
#define MENO 8
char buffer[10];
unsigned long time = 0;
unsigned long timeSet = 0;
int setModeTime = 2000;
const float BETA = 3950; // should match the Beta Coefficient of the thermistor
RTC_DS1307 RTC;
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
void setup () {
pinMode( BACKLIGHT, OUTPUT );
pinMode( CONTRAST, OUTPUT );
digitalWrite( BACKLIGHT, HIGH );
analogWrite( CONTRAST, 40 );
Wire.begin();
RTC.begin();
lcd.begin(16, 2);
Serial.begin(9600);
if (! RTC.isrunning()) {
Serial.println("RTC is NOT running!");
RTC.adjust(DateTime(__DATE__, __TIME__));
}
}
void loop () {
switch (variabile) {
case label:
// istruzioni
break;
case label:
// istruzioni
break;
default:
// istruzioni
break;
lcd.clear();
int analogValue1 = analogRead(A0);
float celsius1 = 1 / (log(1 / (1023. / analogValue1 - 1)) / BETA + 1.0 / 298.15) - 273.15;
lcd.setCursor(0,0);
lcd.print( "Temp Piano 1" );
lcd.setCursor(0,1);
lcd.print(celsius1);
delay(100);
Serial.print("Temp Piano 1");
Serial.print(celsius1);
Serial.println(" ℃");
delay(1000);
lcd.clear();
int analogValue2 = analogRead(A1);
float celsius2 = 1 / (log(1 / (1023. / analogValue2 - 1)) / BETA + 1.0 / 298.15) - 273.15;
lcd.setCursor(0,0);
lcd.print( "Temp Piano 2" );
lcd.setCursor(0,1);
lcd.print(celsius2);
delay(100);
Serial.print("Temp Piano 2");
Serial.print(celsius2);
Serial.println(" ℃");
delay(1000);
lcd.clear();
int analogValue3 = analogRead(A2);
float celsius3 = 1 / (log(1 / (1023. / analogValue3 - 1)) / BETA + 1.0 / 298.15) - 273.15;
lcd.setCursor(0,0);
lcd.print( "Temp Piano terra" );
lcd.setCursor(0,1);
lcd.print(celsius3);
delay(100);
Serial.print("Temp Piano terra: ");
Serial.print(celsius3);
Serial.println(" ℃");
delay(1000);
DateTime now = RTC.now();
lcd.clear();
sprintf(buffer, "%02d/%02d/%d", now.day(), now.month(), now.year());
lcd.setCursor(0, 0);
lcd.print( buffer );
Serial.print("Data: ");
Serial.println(buffer);
char buffer[10] = "";
sprintf(buffer, "%02d:%02d:%02d", now.hour(), now.minute(), now.second());
lcd.setCursor(0, 1);
lcd.print( buffer );
Serial.print("Ora: ");
Serial.println(buffer);
delay(2000);
}
}