timing in an arduino

hi, can some one plz help me with a function that can get me the number of hours elapsed so that i can display the number of days elapsed in an lcd screen since the initialization of a given system?

Can you post the code you have sofar?

The trick is to use the millis() function which returns an unsigned long that counts the milliseconds.

dividing this by thousand gives you the seconds.

dividing the seconds by 3600 gives the hours

you can subtract the whole hours from the number of seconds and then do the math for minutes.

If you want accurate time keeping over a long period you will probably need a Real Time Clock (RTC) module as the Arduino is not an accurate time-keeper.

...R

nzioka:
hi, can some one plz help me with a function that can get me the number of hours elapsed so that i can display the number of days elapsed in an lcd screen since the initialization of a given system?

http://playground.arduino.cc/Main/DS1302

Important note: Cheap modules with the DS1302 and DS1307 often have problems with the crystal and the voltage. They often don't work very well. You are strongly advised to use a DS3231, which is very reliable and accurate and needs only a battery to run (the crystal is inside the DS3231).