TechnoBubba:
Response to dmjlambert (#31)
Anything that uses millis which increments is "doomed" to rollover and requires extra code to work around that problem. Please see #30.
Thanks. 
Would you like to learn why there is no "rollover problem" or extra code involved when you use unsigned variables to do the math. None Whatsoever.
A 12 hour clock is unsigned. Let's do an unsigned subtraction on that and see what happens?
The formula I want to use is: Now - Start = Interval
Now it is 2 and my last time mark, Start, was at 9.
So from 2, I subtract 9 by moving the hand left 9 hours and the result is the hand on 5.
Unsigned variables work like that only with more than 12 positions. No problem with "rollover".
Work it out on paper using 4-bit values, a 16 hour clock but use bits instead of clock hands and don't forget to leave carry or borrow out of it unless you want to count 'days' on the side.
Here's a sketch you can plug values into and see what happens without doing the math yourself.
unsigned long a, b, c;
void setup() {
Serial.begin( 115200 );
Serial.println( "\n unsigned math\n" );
a = 0xffffff00UL;
b = 0x10UL;
Serial.print( "a = ");
Serial.print( a, DEC );
Serial.print( " = 0x");
Serial.print( a, HEX );
Serial.print( " = 0b");
Serial.println( a, BIN );
Serial.print( "b = ");
Serial.print( b, DEC );
Serial.print( " = 0x");
Serial.print( b, HEX );
Serial.print( " = 0b");
Serial.println( b, BIN );
if ( b >= a ) Serial.println( "b >= a" );
else Serial.println( "a > b" );
c = a - b;
Serial.print( "a - b = ");
Serial.print( c, DEC );
Serial.print( " = 0x");
Serial.print( c, HEX );
Serial.print( " = 0b");
Serial.println( c, BIN );
c = b - a;
Serial.print( "b - a = ");
Serial.print( c, DEC );
Serial.print( " = 0x");
Serial.print( c, HEX );
Serial.print( " = 0b");
Serial.println( c, BIN );
c = b - (b + 1);
Serial.print( "b - (b + 1) = ");
Serial.print( c, DEC );
Serial.print( " = 0x");
Serial.print( c, HEX );
Serial.print( " = 0b");
Serial.println( c, BIN );
while( 1 );
}
void loop() {};
I have good working sketches that time contact switch/button bounce using the low 8 bits of Arduino millis. That's good up to 255 millisecond intervals, bounce takes 2 to maybe 20 (extreme case) so I don't bother storing or using 32-bit values to time switch stable states, I can have 4x as many buttons for the same RAM it takes to use 32-bit time values. The number of bits only determines the length of the maximum interval I can time, it's the unsigned part that makes it able to work.