He Said: My first taste of Arduino
Welcome to "He Said", the portion of the show where I get to say WHATEVER I WANT AND NOBODY CAN STOP ME!!! *Ahem* Welcome to "He Said", the portion of the show where I get to talk about cool stuff that I'm doing. I will use this space to write about the hobby projects I'm working on, my latest attempt at data visualizations, and anything else that is on my mind.
So without further ado, my first post is about my first foray into the realm of wearable electronics, where I made this thing!
How did we get here?
Two Christmases ago, Tashia, knowing that I like to read and that I play Dungeons & Dragons, bought me the book Of Dice & Men, by David M. Ewalt. I know, it doesn't seem related, but without this book, I would probably be sitting here several hundred dollars richer and several boxes of electronic doodads poorer.
Ostensibly, the book is a history of D&D, but it's also much more than that. It touches on the history of roleplaying games, and the history of gaming itself. In one chapter, the author describes his experience with Live Action RolePlaying, or LARPing. While I had heard of LARPing before, and the concept sounded interesting (hitting people with fake swords? Yes please!), the actual practice always seems a little too weird for me. The word LARP conjured* the image of dorks in the woods throwing things at each other:
* Pun intended
I read Ewalt's description of his experience at Otherworld, which is a LARP designed primarily for people who aren't total nerdy weirdos, and suddenly this whole running around in the woods throwing things at each other thing started to sound pretty interesting.
So I did some searching on the internet to see what is out there. Otherworld LARP is in Connecticut, and isn't that inexpensive, so, while I definitely want to go some day, it's not very practical for a first time LARP experience. It turns out, though, that there are several games closer to home, and not every LARP is just middle-aged men reliving their Lord of the Ring fantasies! There definitely are some games like that, but there are also medieval games, zombie games, and my personal favorite, post-apocalyptic games. I found one such game in particular, called Wastelands, which takes your standard "the world ended years ago and you must survive it" genre and mixes it with just a twist of trope fantasy. Also you get to use airsoft guns, so now it's running around in the woods throwing things at people, hitting them with fake swords, and shooting them with toy guns. The trifecta!
I like to describe the character I created as "a post-apocalyptic Amish gun-fu cowboy". He's got two giant revolvers, carries a katana and wakizashi, makes people run in fear with just a look, and can occasionally move faster than a speeding bullet, all while trying to bring good into an otherwise lost world. So imagine Neo mixed with your standard western cowboy mixed with a samurai mixed with an Amish person. All in an iconic black hat.
But what's with the lights?
It turns out that a surprising amount of LARPing involves counting while doing other things. You have
to keep track of your health, how many times you use certain skills, and so on. Our game also has a lot of timed effects: healing someone takes a 60-count while pretending to bandage them, a fear spell might last a few minutes, and it takes 5 minutes to repair damaged armor.
It also turns out, as I found in the first few games I played, that I'm not very good at counting, particularly while I'm running around in the woods having things thrown at me, getting hit with fake swords, and getting shot at. So I decided to make a device that does at least some of the counting for me
Ok, so how does it work?
As you can see in my wonderfully annotated picture below, I used a LilyPad Arduino USB to drive the whole thing. Arduinos are programmable microcontrollers, essentially little computers that make it easy to program inputs and outputs. There are a ton of different flavors (including this one I have 4 types of Arduinos in the apartment right now), but the thing that makes the LilyPad version distinct is that it is sewable. So instead of soldering wires together, you use conductive thread, which is like regular thread, but... conducts electricity. It is battery powered, and I hid the rechargeable battery in a little pocket Tashia sewed into the hat for me.
The output part of the equation are five sewable, addressable RGB LEDs, also known as LilyPad Pixels. They are very easy to use, and can be daisy-chained together so that they require only power and one data line. Each pixel lights up in turn, and represents 60 seconds. The pixel is solid green at 60 seconds, slowly fading to yellow at 40 seconds, then red at 20 seconds, then fading to black when no time is left on the pixel. If all the lights are green it means you have 5 minutes on the clock, and at any point if there are more than 5 minutes left all the lights shine blue.
The input part of the equation comes in the form of five sewable buttons. The "+30s", "+60s", and "+300s" buttons add that many seconds to the timer and starts the countdown. I chose those values so I'd have one-press access to the most commonly-used timing lengths, as well as being able to use multiple pushes to get most any other value.
This is what it looks like to press the +60s button 6 times
Even at 3.7V and accounting for the voltage drop from the conductive thread, the pixels are bright! Since the LEDs end up being right in front of my eyes, I added a "brightness" button to help keep myself from being blinded. Each push causes the lights to get a fraction dimmer, and once they reach the minimum dimness they go back to the brightest setting again.
Lastly, the "night/mute" button cycles through a couple different modes the hat can be in. "Night" mode turns all the LEDs red, to provide some light without killing my night vision. Pushing it again puts it in "Day" mode, where all the lights turn white (though, for reasons I'll get to in a future post, currently day mode is more of an orangy red than an actual white). Pushing it a third time puts it in "mute" mode, which just turns off all the LEDs, regardless of the timer status. Pushing it one more time cycles back to the standard mode.
So in conclusion...
The timer hat made for a nice first project. Being able to sew my parts together definitely took down the intimidation factor and at the same time made it easy to integrate into my costume. Additionally, since the pixels use a library freely available from AdaFruit which simplifies addressing and controlling the LEDs, I was able to spend the majority of my time on this project on learning to program the Arduino instead of how to work the lights. Luckily it uses a variation on C# so there were lots of examples and tutorials on the internet to get me going in the right direction.
The final result ended up turning out very well. I had some problems with loose/intermittent connections, since the stiffness of the hat allowed it to flex and come apart from the stitches. I think a more flexible fabric would have allowed the stitches to bend and move in the same way as the material. Also, as I alluded to above, I had some issues getting the full power from the battery to transmit all the way to the pixels.
On the plus side, the countdown function greatly simplified gameplay for me. I could push the 5 minute button during a downtime or during story exposition and put my full attention to whatever was going on outside of my personal bubble, instead of having to do nothing but count to 300. In some cases it takes away from the roleplaying aspect a bit, but on the other hand, spending 5 minutes pretending to patch up your armor is boring.
All in all I'm glad I did this project. In fact, I've already created another Wastelands timer for Tashia (this one is an arm bracer -- look out for a blog post about it in the future) and bought the parts for two more projects, one of which will hopefully be finished by Christmas.
PS: ever wonder what a post-apocalyptic Amish gun-fu cowboy looks like? Take a gander! (Special thanks to my friend Morgan Pencek for the awesome photos!)