calculated that the larger LEDs
have about 2. 8 times the cross-sectional area as the smaller
ones. It turned out that using
small LEDs with luminance
ranging from 250 to 310 mcd
and large LEDs with luminance
ranging from 680 to 700 mcd
worked very well.
Next, I hooked up a buzzer
(BZ1) between an I/O line and
+5V (Figure 5). I added 150Ω
(R9) in series for some current
limiting, as the buzzer was
designed for three-volt
operation. I later determined
that 33Ω was sufficient and
ended up using two 75Ω resistors in parallel for an
equivalent resistance of 37.5Ω.
It was fairly trivial to get it to buzz near its resonance
frequency of 2 kHz. I had already set up an interrupt to
trigger every 256 µs (I’ll go over the software in Part 2). All
I had to do was pull the output line down on one
interrupt, then release it on the next interrupt; this created
a square wave with a period of 512 µs, or 1,953 Hz.
60 Hz Input
I had an idea to connect each pushbutton
to a line in the LED matrix. The other side of
the buttons and the 60 Hz signal would be
connected together — adding diodes in series
for isolation — to the input-only pin (RA5). A
pull-up resistor to +5V would be added to the
To read the switches, I would pull down
the line to one switch (while all other LED
lines were floating in a high-impedance state)
and read the result on RA5.
One problem with this circuit was that
while a button was held down, the pull-up
resistor would feed voltage into the LED
matrix. Even with a fairly high value for the
pull-up resistor, it would cause random LEDs to
The other issue I quickly realized was that
when the microcontroller was holding down
one of the switch lines, current would feed
through the LEDs to the other switch lines —
effectively holding them partially down.
The other lines would not drop to ground,
It became apparent that an analog pin for the button
input would need to be used. Therefore, I decided to
March 2018 27
■ FIGURE 6. Test circuit schematic with AC input added.
■ FIGURE 5. Test circuit schematic with buzzer added.