Sei sulla pagina 1di 1

#include <Wire.h> //include Wire.

h library
#include "RTClib.h" //include Adafruit RTC library
#include <dht.h>
#include <LiquidCrystal.h>
char c;
#define dataPin 12 // Defines pin number to which the sensor is connected
dht DHT; // Creats a DHT object
LiquidCrystal lcd(5, 6, 7, 8, 9, 10);
RTC_DS3231 rtc; //Make a RTC DS3231 object

//Set the names of days


char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"};

void setup ()
{
Serial.begin(9600); //Begin the Serial at 9600 Baud

//Print the message if RTC is not available


if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
while (1);
}

//Setup of time if RTC lost power or time is not set


if (rtc.lostPower()) {
//Sets the code compilation time to RTC DS3231
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));

lcd.begin(16,2);
}
}

void loop ()

{
//Set now as RTC time
DateTime now = rtc.now();
lcd.clear();
lcd.setCursor(0,0);
//Print RTC time to Serial Monitor
Serial.print(now.year(), DEC);
lcd.print(now.year(), DEC);
Serial.print('/');
lcd.print('/');
Serial.print(now.month(), DEC);
lcd.pr
lcd.print(" % ");

delay(2000);
delay(3000);
}

Potrebbero piacerti anche