# RTC time reset

I’m using STM32F103C8T6 board in arduino IDE,and this board has RTC in it,so my RTC is counting seconds (1,2,3,4,5,6,7…200,201,202…) And I would like my program to reset time to 0 when it reaches 86400 (24 hours) and when it resets to 0 start counting agin like before

#include <RTClock.h>

RTClock rt (RTCSEL_LSE); // initialise
uint32 tt;

void setup()
{
Serial1.begin(9600);

}

void loop() {
int day = 86400;
if (rt.getTime()!=tt) {
tt = rt.getTime();
Serial1.print(tt); }
if (tt == day){
tt = 0; //Should reset time to 0
//do something
}
}

Hi,

what is the problem? What is not working? At the moment, I cannot tell by your post. You can use code-tags [ code ] to enhance the readability of your posts.

Best

I wan't time to be reset to 0 when it reaches 86400 but it doesnt work (86398,86399,86400,0,1,2,3,4....)

Well, try this code

``````#include <RTClock.h>

RTClock rt (RTCSEL_LSE); // initialise
uint32 tt;

void setup()
{
Serial1.begin(9600);

}

void loop() {
int day = 86400;
if (rt.getTime()!=tt) {
//    tt = rt.getTime();
tt++;
Serial1.print(tt); }

if (tt == day){
tt = 0;     //Should reset time to 0
//do something
}
}
``````

Why not simply increment tt every second?

Thank you so much this works :) Can you pleese tell me why is there "!" before = (!=) it means not equal,right? Also what does ++ mean in "tt++;". Thanks

Glad it helped. "!=" does mean unequal, yes. t++ is short for "t = t +1;"

Best

Thanks alot you helped me :)