I just finished mentoring a high school student in the build of a 4×4×4 LED cube for his senior project. I was sitting at the desk, looking at a small pile of LEDs left over from the build, trying to think of something fun to do with them, when my three-year-old daughter walked in, sat down, and started playing with her Lite Brite. The pegs, I realized, looked just like LEDs, which was all the inspiration I needed. Let’s build a clock!
The challenge of this project is to discretely control 46 LEDs using a microcontroller that only has 20 I/O pins. The Lite Brite LED Clock utilizes common-cathode/common-anode multiplexing techniques and persistence of vision to lower the pin count demands on the microcontroller.
To light up a particular LED, set the row the LED is on to LOW and the column the LED is on to HIGH. The benefit to having LEDs arranged in a common-cathode/common-anode configuration is that we can use a relatively small number of microcontroller pins to discretely control each LED. The drawback to this arrangement is that we can only choose one LED to light at a time.
With the limitations of human vision and the speed of the microcontroller, however, we can effectively light multiple LEDs simultaneously. To display the letter W, for example, we would light the first LED, turn it off, light the second LED, turn it off, and so forth until we have lit and unlit each LED in the W pattern. After the last LED is turned off, we start the process over again. The refresh rate is so fast that our eye sees all the LEDs as constantly on.
One effect of multiplexing LEDs this way is that they are dimmer than they would be if supplied with constant current. At first, I tried to supply the two dots of the colon with constant voltage since they would always need to be on anyway. The result: the colon was about ten times brighter than the numbers. The fix: assign the dots of the colon pins on the LED matrix, and turn them on/off at the same rate as the rest of the display.