Skip to content

Instantly share code, notes, and snippets.

@Ryanhu1015
Created July 3, 2017 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ryanhu1015/59078081f05ed5351e3182cd77bc78ef to your computer and use it in GitHub Desktop.
Save Ryanhu1015/59078081f05ed5351e3182cd77bc78ef to your computer and use it in GitHub Desktop.
software_RTC
unsigned long timeNow = 0;
unsigned long timeLast = 0;
int seconds = 0;
int minutes = 0;
int hours = 0;
int days = 0;
timeNow = millis()/1000;// millis is the function i have mentioned above
seconds = timeNow - timeLast;
if (seconds == 60)
{
timeLast = timeNow;
minutes += 1;
}
if (minutes == 60){
minutes = 0;
hours += 1;
}
if (hours == 24){
hours = 0;
days += 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment