I tried to set time and date on mega and wiznet with the below code, but no message on serial monitor...
what is wrong??
#include <Wire.h> #include <Rtc_Pcf8563.h>
//init the real time clock
Rtc_Pcf8563 rtc;
void setup()
{
//clear out the registers
rtc.initClock();
//set a time to start with.
//day, weekday, month, century(1=1900, 0=2000), year(0-99)
rtc.setDate(14, 6, 3, 1, 10);
//hr, min, sec
rtc.setTime(1, 15, 0);
}
void loop()
{
//both format functions call the internal getTime() so that the
//formatted strings are at the current time/date.
Serial.print(rtc.formatTime());
Serial.print("\r\n");
Serial.print(rtc.formatDate());
Serial.print("\r\n");
delay(1000);
}
still no answer:( nothing happens on serial...this code was working fine on atmega328...but mega2560 now... :~
I have read on playground I should define I2C addresses...like #define RTCC_R 0xa3 #define RTCC_W 0xa2
ok, now it is answering after this:
include <Wire.h> #include <Rtc_Pcf8563.h> #define I2C_RTC 0x51
//init the real time clock
Rtc_Pcf8563 rtc;
void setup()
{
Serial.begin( 9600 );
//clear out the registers
rtc.initClock();
//set a time to start with.
//day, weekday, month, century(1=1900, 0=2000), year(0-99)
rtc.setDate(15, 4, 11, 0, 12);
//hr, min, sec
rtc.setTime(21, 52, 0);
}
void loop()
{
//both format functions call the internal getTime() so that the
//formatted strings are at the current time/date.
Serial.print(rtc.formatTime());
Serial.print("\r\n");
Serial.print(rtc.formatDate());
Serial.print("\r\n");
delay(1000);
}