Hi
I'm working on a clock project and my main loop is looping more often than planned.
Here are some setup lines -
#include "RTClib.h"
RTC_DS3231 rtc;
Here's the start of the loop code -
void loop()
{
int current_seconds = 255;
do
{
DateTime now = rtc.now();
seconds = now.second();
minutes = now.minute();
hours = now.hour();
day = now.day();
month = now.month();
year = now.year()-2000;
}
while (seconds == current_seconds);
current_seconds = seconds;
Serial.println(seconds);
Serial.println(current_seconds);
The same seconds and current_seconds values are printed several times.
The do ... while loop is not waiting for the next second before dropping down and updating the displays.
All of the time and date values are actually correct.
I've been looking at this for ages and nothing stands out.
I think that it's probably a really simple one.
Please can anyone else see the issue ?
Thanks