Toll-Free Customer Support 24/7

Real Time Clock

/*
* Project name:
Real Time Clock
* Copyright
(c) Researchdesignlab.com
* Description:

* Test configuration:
MCU: ATMEGA328
Dev.Board: Arduino uno
Oscillator: 16 MHz
Software: Arduino

*/

#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;
char rec;
void setup()
{
Serial.begin(9600);

Wire.begin();
RTC.begin();

RTC.adjust(DateTime("Jun 13 2014","17:11:45")); // Setting the time to a fixed value. If you want to use the system time comment this line and use the option below

}
void loop()
{
DateTime now = RTC.now();// Getting the current Time and storing it into a DateTime object
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
delay(1000);
}

Back to top