At the time of this writing, the badge design is not completely finalized, though there are a couple LED circuits that won't change. Figure 1 is a 3D model
of the preliminary design. In one section, there are six
blue LEDs connected to three resistors and three I/O pins;
in another section, the six LEDs of two RGB modules are
similarly wired. Wait ... how do we control six LEDs with
only three I/O pins?
named after its
inventor, Charlie Allen
— is a method of LED
control that takes
advantage of the
processor's ability to
manipulate the pin
state: a pin can float
(input mode); be an
output and low; or be
(the term tri-state refers
to the pin's ability to
be in one of three
states). We don't often
think of the input state
as an output control mechanism, but it's critical to the
operation of Charlieplexing. Okay, then, let's start dirt easy
with two LEDs (see Figure 2).
If we make P0 high and P1 low, current will flow
through D1 and light; D2 is reverse-biased and will not
light. If we reverse the outputs and make P0 low and P1
high, D2 will light and D1 will be extinguished.
Now, what if we make P0 or P1 an input (i.e.,
floating)? When this happens, the pin is disconnected from
the output driver which is like opening a switch. Both
LEDs will be extinguished, regardless of the state of the
other pin. This is key to Charlieplexing.
With this understanding, have a look at Figure 3 and
the corresponding logic table in Figure 4. The circuit
shows the beauty of the
Charlieplex arrangement: With
just three I/O pins, we can
control up to six LEDs. Getting
down to the nitty-gritty, using
allows us to control up to n *
(n - 1) LEDs with n I/O pins.
This means four pins could
control 12 LEDs, five pins
could control 20, and so forth.
As you study the table in
Figure 4, you'll see that one
pair of outputs which is
connected across the target
LED is set to high (H) and low
(L), while the third output is set
to the input/floating state (X);
Fun with Charlieplexing
Back in May, my friend Ken Gracey (CEO of
Parallax) tweeted about a project they're
working on: a Propeller-powered convention
badge for any event that needs one. This
was inspired by the success of the DEFCON
22 badge which I had the privilege to help
design and write code for. There are lots of
tech conventions around the world, yet not
everyone has the budget to design custom
hardware. This is where Parallax intends to
help out. They'll build the badge — you
write cool custom code for your venue.
THE SPIN ZONE ADVENTURES IN PROPELLER PROGRAMMING
■ BY JON MCPHALEN
August 2015 15
■ FIGURE 2.
■ FIGURE 1. Hackable badge.
■ FIGURE 3. Six LEDs.
■ FIGURE 4. Charlieplex