to solder a couple 1x3 male headers into the module
to make it breadboard friendly. When you're done,
the module will look like the one in Figure 2.
Down the line, I intend to roll my own. Figure 3
is the schematic for my JM_Pixel module (Adafruit
does not provide a schematic for the NeoPixel.
There's nothing magic about this circuit; it's taken
right from the WS2812 datasheet. The RC
components between VDD and VCC keep PWM
noise on the VDD line from bothering the control
electronics (which are connected to VCC). Easy
peasy. Serial data is fed into DIN. When the device
has received 24 bits, the rest of the stream will be
directed to DOUT for other modules.
The signal from the DOUT pin is
re-shaped and amplified so that it
doesn't degrade as data propagates
from LED to LED. According to the
datasheet, we can have up to five
meters of wire between WS2812
modules. I'm not sure I'd push it that
far, but I like that they don't have to
be right on top of each other.
One note on my version (see
Figure 4): The pins are organized
differently than the NeoPixel; my
printed circuit board (PCB) layout
matches the polarity of female-to-female servo extender cables. I've included Dip Trace files
and Gerbers for the JM_Pixel. If you order from Bay Area
Circuits (see File Menu in Dip Trace PCB) using the 10-day
production schedule, you can get 100 boards for about
$36 with shipping. Add $0.50 for the LED (from Adafruit)
and another dime for the resistor and capacitor, and you
can build your own pixels for
about a buck each — if you're
willing to do the soldering.
Cracking the
WS2812 Code
As a programmer, I do my
best to wear a "Captain
Obvioso" costume so that
everyone can understand what
I'm doing — and most of the
time it works. To that end, I like
to specify RGB colors in my
projects as a long value in the
form $RR_GG_BB. Here's the
rub: The WS2812 wants the 24-
bit packet to arrive as
$GG_RR_BB (the RR and GG
bytes are swapped).
It's easy to swap a couple
bytes in code, but on asking for suggestions in the
Propeller forum, a really interesting discussion ensued and
in the end, the most clever solution — in my opinion —
was by TonyP12 (his handle) who is a frequent and very
helpful contributor in the Parallax forums. He came up
with a trick that eliminates nine lines of code and three
ADVENTURES IN PROPELLER PROGRAMMING
■ FIGURE 2. NeoPixel module.
■ FIGURE 4. JMPixel PCB.
■ FIGURE 3.
JMPixel schematic.
September 2013 51