reset. When the value in scan is 11, the button is being
held down, hence the timer is incremented. Finally, when
the value in scan is 10, we have detected the falling
edge of the button input. This could, of course, be contact
You can see that most of the work is done when scan
is 10 (end of input). The first step is to compare the
timer to a normal press (which we set from 50 ms to
500 ms). If this is the case and the program is not in
"party" mode (more on that in a
moment), the animation state
control variable is incremented.
If a long button press is
detected, the animation state is
checked before acting. If we're in
animation mode (for the runway),
we reset the state to off. This was
important to allow Jinyo to change
to a fresh battery pack before his
model went out.
After changing to fresh
batteries, he could press the button
to verify everything is working. With
that test done, a long button press
would reset the animation to off.
Those of you who have been to
a Comic-Con understand that they
are very social events, and Jinyo
envisioned his model wearing the
dress to a party after the fashion
show. For this, he requested a
"party" mode that was a standard
Larsen scan of the LEDs, but at a
significantly reduced brightness.
WS2812s can be very bright, and in
the dim environment of a cocktail
party, he didn't want the dress
blinding other guests!
Of course, for the normal
animation mode on the runway, we
used full brightness. (By the way,
the dress was a huge hit!)
Putting a Button
Well, we've done it! We've
completed another year ... well
done, us! I'm sure that more than a
few of you started reading this
column thinking, "Really? How
much is there to say about button
inputs?" Quite a lot, actually, and I
From my family to yours, I wish you the best this
holiday season. Happy Hanukkah! Merry Christmas!
Happy New Year!
Until next time, keep spinning and winning with the
December 2014 23