is identical to the test circuit.
Figure 5 shows the microcontroller. R1-R14 are the
current-limiting resistors for the Charlieplex LED matrix
(CP_Bus). The buzzer is connected to the correct I/O line
RA4 and now has 37.5Ω in series instead of 150Ω. R20 is
the current-limiting resistor for the 60 Hz input line and
D9 provides clamping to +5V.
Figure 6 is the Charlieplexed LED matrix — 182 LEDs
connected to the 14 line CP_Bus. It still amazes me that
this even works!
The four pushbuttons are shown in Figure 7. The
switches are read on CP12, which is connected to RA0 —
another analog input line on the microcontroller. A simple
change in the code connects RA0 to the internal
comparator instead of RA2 used in
the test circuit.
I wrote the microcontroller
program in assembly language. I
chose this because I was already
very familiar with Microchip’s PIC
assembly language, and I needed
precise control over the timing of
certain parts of the program. It
also helped that Microchip’s
MPLAB Integrated Development
Environment (IDE) — which is used
to compile assembly language — is
available from their site free of charge (see Resources).
To make writing, debugging, and editing the software
easier, I broke the program up into different sections, each
in its own file. The software source files are available with
the article downloads. When you look at the code, you’ll
see that I’m a firm believer in putting lots of comments in
The Interrupt Routine
Timing issues are crucial to the operation of the clock.
It must keep correct time which is accomplished by
monitoring the 60 Hz line signal coming from the wall
transformer. In addition, since only one LED can be lit at a
May/June 2018 31
■ FIGURE 6. LED matrix schematic.
■ FIGURE 7. Pushbutton schematic.