Record a duration of time as data I have very little experience with the Arduino and am hoping that you may provide me with some helpful info.

I would like to build a device that records time spent on a project.  I envision the main Uno with a switch, microSD breakout, and an LED to indicate its tracking your time. When setup the user could simply press the switch/button (light up the LED to show you're "working") and while you plug away on your day job the Uno will track the time between switch on and switch off. Then at the time the switch is turned off, have the Uno write a simple data file containing the total time spent on that activity.

I have a basic idea of what I need hardware wise, but am hoping to find insight to the backbone of software programming to make something like this begin to take shape.
There are two ways of doing this:


Using a Real Time Clock (RTC) chip, which you connect to your Arduino.
Using the millis() function of the Arduino.


Needless to say, they aren't completely the same in efficiency. An RTC is a dedicated chip for measuring time and is incredibly accurate. The millis() is not as accurate, but still pretty accurate.

So, it really depends on how accurate you want it to be. You can make millis() more accurate through code, which isn't something difficult. But an RTC always works fine and is always more accurate, if only by milliseconds. In general: need to time long durations, an RCT is probably better.

Regardless of the method you will use, you can convert the data into the desired format so it can be read easily when looking at the files on the SD card. So, for example: you can write code that simply checks how many hours fit in the saved time data, and after that you can check the minutes and even after that you can check for the last seconds. For this you're going to need modulo.

Here are some resources you might want to check out:


An Arduino tutorial for an RTC chip: http://playground.arduino.cc/Main/DS1302
Official documentation on millis(): https://www.arduino.cc/en/Reference/Millis