these all have the same value, and we apply 5V at
the top and 0V at the bottom, we can tap into the
ladder with push buttons and extract the voltages
shown. If we have more resistors — 16, for instance
— each step can be
7 of a volt.
The 28X1 has some ADC inputs, each of which is
connected internally with an analog-to-decimal
converter. The chip senses voltage applied to a pin
and converts it into a digital value from 0 through
255. If we make a ladder with 16 evenly spaced
steps, using 150-ohm resistors, and we tap into
them from 0 volts upward, the PICAXE will convert
the voltages to values 0, 15, 31, 47, 63, and so on,
up to 255.
Actually it’s a little more complicated than this,
because we can’t allow the ADC input pin to “float”
in an unconnected state when no button is pressed.
I added a 100K resistor to take care of this (Figure J,
How can all of this be incorporated into the existing program? Really, you need a new program, and
I already wrote it for you under the title Zap-a-Mole
Extreme, available for download along with a schematic and parts list.
150 Make: Volume
More With Your Moles
Is that it? Not really. You could make a snazzy, playable enclosure for the game (Figure K.) And there
are always more things to think about.
You could look up matrix encoding, for instance,
to find an alternate way of sensing multiple devices
with a smaller number of inputs, or driving multiple
devices with a smaller number of outputs. Matrix
encoding is an important topic, because it’s used so
often — for example, to address memory locations
inside a computer.
You can also find matrix-encoded 4× 4, 16-key
keypads available cheap online. Maybe you could
use one for the game? You could buy surface-mount
LEDs and glue one to each button on the keypad.
Getting voltage to them could be tricky — but I leave
that to you.
How about adding a feature to adjust the game difficulty? The running speed could be controlled using
a potentiometer hooked up to another ADC input.
And lastly, no game is complete without audio.
The PICAXE can handle this, too; check the sound
command in the BASIC manual (link below).
All of these improvements are enabled by the
flexibility and power of a microcontroller. It can
substitute for dozens of old-school logic chips, and
if you take some time to learn the language that it
understands, you can make it behave almost like a
real computer. Not bad for a component that costs
Program listings and schematics for »
Zap-a-Mole Enhanced and Extreme:
Data sheet for CD74HC4514 (PDF): »
Binary arithmetic primer: »
PICAXE installation and other info (PDF): »
PICAXE BASIC manual (PDF): »
Charles Platt is the author of Make: Electronics, an introductory guide for all ages. A contributing editor to MAKE, he
designs and builds medical equipment prototypes in Arizona.