Here is a simple program that calls up DateTime now, prints now.day correctly and then attempts to set a volatile variable (dy) and a variable (day) to now.day and then prints the two variables. Both are printed as 10. Finally now.day is printed again for proof.
The output is
23 today's date correct.
10 error
10 error
23 Proof that now.day is not corrupted.
I hope an expert can solve this in microseconds for me.
Code: Select all
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;
volatile int dy=0;
int day=0;
void setup()
{
Serial.begin(9600);
Wire.begin();
RTC.begin();
delay(100);
}
void loop()
{
DateTime now = RTC.now();
Serial.println(now.day(), DEC);
dy=(now.day(), DEC);
Serial.print(dy);
Serial.println();
day=(now.day(), DEC);
Serial.println(day);
Serial.println(now.day(), DEC);
Serial.println();
delay(2000);
}