need help for a menu to setup Clock Modul DS1307

I have attached some test code I wrote to adjust date and time on a DS3231 using a rotary encoder with integral push button. I have altered the code to use buttons to simulate the encoder turning so it should work okay using 3 buttons now. The DS3231 is similar to the DS1307 so the attached library might work without alteration, if not then this is the library to use GitHub - davidhbrown/RealTimeClockDS1307: Yet another DS1307 Real-Time Clock library for Arduino (obsolete) As I don't have a LCD I will leave it to you to replace the Serial.print stuff with LCD relevant stuff.

A tip to improve your DS1307 accuracy is to apply a time offset every hour. Say your gaining 12 seconds per day this equates to half a second per hour. The below code snippet will retard the RTC by 500 milliseconds per hour. Just work out how much the clock is gaining per hour and adjust delayComp as needed.

const long delayComp = 500;                 // half second per hour drift

    static boolean driftApplied = false;
    RTC.readClock();
    int m=RTC.getMinutes();

    // RTC Drift compensation
    if(m == 0)                              //Is it top of hour
    {
        if(!driftApplied){                  //Have I already done drift compensation
            delay(delayComp);               //Apply delay
            RTC.setClock();                 //Set clock
            driftApplied=true;              //Signal drift applied
        }
    }
    else {                                  //Not top of hour
        driftApplied = false;               //Reset drift applied
    }
    // Do rest of clock code here

ClockSet.ino (7.18 KB)

RealTimeClockDS3231.cpp (11 KB)

RealTimeClockDS3231.h (4.4 KB)