The clock, as I’ve previously described it, can be in one of 24 possible states, because there are 24 hours in a day. Each hour “segment” of the clock can be in one of three possible states — red, yellow, or green, but red and yellow are really the same state based on whether the time is AM or PM.
I’m thinking of making an Arduino the heart of the clock. It’s a bit of overkill, but I guess I can have a fancy light display for the change of the hour or something like that.
The Arduino has thirteen digital outputs (or inputs, as the case may be). One way to hook things up would be to have each output control a single section of the clock, and use the final one to determine AM/PM. Unfortunately, this doesn’t leave any way to change the time.
There are 24 possible states for the clock face. The minimum number of outputs needed to represent this is 5, since 25=32. However a lot of fairly complex logic would be required to get the clock working in this case: 12PM would be “01100″ and 4PM would be “10000″ — here’s a table of each possible output when using five pins this way, the corresponding time, the color that the “9′o’clock” segment should be.
| Pin 1 |
Pin 2 |
Pin 3 |
Pin 4 |
Pin 5 |
Time |
Color |
| 0 |
0 |
0 |
0 |
1 |
12:00:00 AM |
GREEN |
| 0 |
0 |
0 |
1 |
0 |
01:00:00 AM |
GREEN |
| 0 |
0 |
0 |
1 |
1 |
02:00:00 AM |
GREEN |
| 0 |
0 |
1 |
0 |
0 |
03:00:00 AM |
GREEN |
| 0 |
0 |
1 |
0 |
1 |
04:00:00 AM |
GREEN |
| 0 |
0 |
1 |
1 |
0 |
05:00:00 AM |
GREEN |
| 0 |
0 |
1 |
1 |
1 |
06:00:00 AM |
GREEN |
| 0 |
1 |
0 |
0 |
0 |
07:00:00 AM |
GREEN |
| 0 |
1 |
0 |
0 |
1 |
08:00:00 AM |
GREEN |
| 0 |
1 |
0 |
1 |
0 |
09:00:00 AM |
YELLOW |
| 0 |
1 |
0 |
1 |
1 |
10:00:00 AM |
YELLOW |
| 0 |
1 |
1 |
0 |
0 |
11:00:00 AM |
YELLOW |
| 0 |
1 |
1 |
0 |
1 |
12:00:00 PM |
GREEN |
| 0 |
1 |
1 |
1 |
0 |
01:00:00 PM |
GREEN |
| 0 |
1 |
1 |
1 |
1 |
02:00:00 PM |
GREEN |
| 1 |
0 |
0 |
0 |
0 |
03:00:00 PM |
GREEN |
| 1 |
0 |
0 |
0 |
1 |
04:00:00 PM |
GREEN |
| 1 |
0 |
0 |
1 |
0 |
05:00:00 PM |
GREEN |
| 1 |
0 |
0 |
1 |
1 |
06:00:00 PM |
GREEN |
| 1 |
0 |
1 |
0 |
0 |
07:00:00 PM |
GREEN |
| 1 |
0 |
1 |
0 |
1 |
08:00:00 PM |
GREEN |
| 1 |
0 |
1 |
1 |
0 |
09:00:00 PM |
RED |
| 1 |
0 |
1 |
1 |
1 |
10:00:00 PM |
RED |
| 1 |
1 |
0 |
0 |
0 |
11:00:00 PM |
RED |
So, the rule just to determine if the yellow LEDs for the 9 segment should be on would be something along the lines of “Light up if ((Pin 2 AND Pin 4) AND NOT (Pin 3)) OR ((Pin 2 AND Pin 3) AND NOT (Pin 4 OR Pin 5))”
Yikes. Complex! Poking around Wikipedia gives some hints on how to make this slightly better, but nothing based on an output of 5 pins is going to be simple. Fortunately, there are some things that I can do to make things easier for myself…