writing program with delay

Dear all,

i need help on simple coding,

i need function that will execute for every 1 minute. parameter it take time (hour:min:second).

for every 1 minute it check whether hour.min.sec has changed or not.

if hour.min.sec is changing

continue;

else

add 1 minute and write to RTC

how we can write in arduino platform.

A few things:

What RTC are you using? I’ve used the DS1307 – [according to a bildr post by SF, its drift is approx ±1 min / month. DS3234 is ±1 min / year.

Let’s presume that you’re asking this because you don’t want to bother with re-calibrating the RTC in the future (the DS1307 does deviate approximately ±2 seconds per day using the above calculation). Let me know if this is your intention.

First, keep in mind that the Arduino itself has some drift, as well. [One project experienced 2 minutes of drift per day. This may be like asking someone who’s wasted drunk to watch over someone who’s a bit tipsy – the Arduino may be much worse off than the RTC in terms of correcting time. Therefore, this won’t be a good path unless you’re using an Ethernet connection to keep your Arduino’s time in check.

But to answer your code question, if you use the DS1307 and the Arduino-RTC library RTClib, there’s a built-in function for adjusting the time.

#include "RTClib.h"

RTC_DS1307 RTC;

RTC.adjust(DateTime(<date here>, <time here>));

[Get the Arduino library here and [learn how it works here. You can learn how to add libraries on the Sparkfun website.

EDIT: As a charitable bloke, I’ll provide the [how-to for adding Arduino libraries here in case you need it.](Installing an Arduino Library - SparkFun Learn)](Understanding the Code | DS1307 Real Time Clock Breakout Board Kit | Adafruit Learning System)](GitHub - adafruit/RTClib: A fork of Jeelab's fantastic RTC Arduino library)](Wires Crossed Blog: Arduino Clock Drift)](http://bildr.org/2011/03/ds1307-arduino/)

I never find any drift in the RTC .I find it got hanged.

for above problem i used timer library for check RTC working or not

and project you mentioned there is bug in the program.