how to keep time on an arduino

Hi
Does anyone know how to keep time on an arduino without an external RTC . Can u set the time through a serial connection and have it output to an LCD and if it is possible is it accurate
hope you can help thanks

Look at the Time library, TimesAlarms also if you need to run code at specific times.
http://playground.arduino.cc/Code/time

dansam8:
Hi
Does anyone know how to keep time on an arduino without an external RTC . Can u set the time through a serial connection and have it output to an LCD and if it is possible is it accurate
hope you can help thanks

Yes, Time library may be of use to you. However you would have to put a value on 'accurate' as using the arduino clock speed as the time base may not be accurate enough for your use. Mins per day may not be accurate using that way and then only an external RTC module would be useful for your application.

Perhaps running this millis() command.
First, calculate what (milli)second of the day it is. For example, 24 hours * 60 minutes* 60 seconds. If its 1:13 AM, it would be 613 minutes into the day, and about 3600 seconds. Put that into the serial monitor. Then, perhaps, by creating two variables; the millis() reading at that moment and the serial number. I believe to store it you can use Serial.parseInt(). To print the time, use millis(), then subtract the original millis variable you created. Finally, add the millis since 12 AM. Then, you can do math to figure out the hour, minutes, and seconds. I'm not going to provide code, but modulo (look it up) will be useful.

Accuracy depends. If you want really good accuracy, you can get a higher-quality clock and wire it in to the Arduino's ATMEGA chip. That would be more accurate. Depending on your math, this would be fairly accurate, down to the millisecond. (Every time you reset the arduino, however, you'd need to reset the clock, unless you used EEPROM.)