DS 3231 RTC set by buttons ?

Hello,
I want to create a clock with an oled display and an RTC DS3231.
I could make things running as I wanted to. Display works and I can see the Time and anything else. But, how can I set the time by using buttons ?

just as an easy example: I want to push a button and then the hours or minutes shall rise. How can I do it ?
If I upload the example code, it can set itself by using this line:
rtc.adjust(DateTime(F(DATE), F(TIME)));

I also can set the clock by using this line of code:
rtc.adjust(DateTime(2023, 9, 27, 9, 30, 0));

I tryed something like this as a button function.
rtc.adjust(DateTime(now.hour()+1));
It did compile but didn´t work !

Can someone help ?

Could this example from a DS 3231 library be a useful start
https://github.com/NorthernWidget/DS3231/blob/master/examples/DS3231_set/DS3231_set.ino

It probably did work, but you need to refresh your display.

Yes that looks better. I just thought to try it with another example. It just sucks that there is almost no explanation how to use a library. Everybody cooks his own soup !

I will try some other examples now.
...to be continued...
cheers !

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.