Time difference of 6 hours?
in code below, function readds3231(); displays different time resulting clock.gettime(year, month, date, dow, hour, minute, second);
why be?
why be?
code: [select]
/*
ds3231_test.pde
eric ayars
4/11
test/demo of read routines ds3231 rtc.
turn on serial monitor after loading check if things are
working should.
*/
#include <ds3231.h>
#include <wire.h>
ds3231 clock;
bool h12;
bool pm;
byte aday, ahour, aminute, asecond, abits;
bool ady, a12h, apm;
byte year, month, date, dow, hour, minute, second;
void setup() {
// start i2c interface
wire.begin();
// start serial interface
serial.begin(9600);
}
void readds3231()
{
int second,minute,hour,date,month,year,temperature;
second=clock.getsecond();
minute=clock.getminute();
hour=clock.gethour(h12, pm);
serial.print(hour,dec);
serial.print(':');
serial.print(minute,dec);
serial.print(':');
serial.print(second,dec);
serial.print('\n');
}
void loop() {
readds3231();
serial.print('\n');
clock.gettime(year, month, date, dow, hour, minute, second);
serial.print(hour, dec);
serial.print(":");
serial.print(minute, dec);
serial.print(":");
serial.println(second, dec);
delay(1000);
}
how did set time on clock ?
Arduino Forum > Using Arduino > Programming Questions > Time difference of 6 hours?
arduino
Comments
Post a Comment