November 3, 2010

923 words 5 mins read

Arduino Makes Halloween Better!

Halloween is my favorite holiday of the year. It’s a fun holiday where people get to mess around, have a good time… and family isn’t involved. For me, since about middle school, it’s been all about the decorating. I’ve done a lot of different decoration effects over the years, once I went as far as turning our 3 car garage into an haunted house once. This year wasn’t quite so elaborate, but it was greatly improved by the use of Arudino.

The key component, my motorcycle.
My plan this year was formed just hours in advance of the holiday. I didn’t really have a plan per se, I just got an idea and ran with it. My goal was to make a “crime scene” in the driveway, simple enough. The basics were: a taped body outline on the ground partially run over by a car, a plethora of “POLICE LINE — DO NOT CROSS” and “CAUTION” tape and the key piece, my black and white BMW R1100RTP (retired police model).

Police car with emergency lights Scott Davidson CC-BY-2.0
The entire idea revolved around my realization that I could use Arduino to easily build the one piece my motorcycle is missing: emergency lights. After all, one of the first things you learn with Arduino (the equivalent to “Hello World”) is blinking an LED. I had already taken that and extended it into playing with and controlling a Tri-Colored (RGB) LED. I knew that the Arduino had a limited amount of power, which limited the number of lights I could do, but I knew I could program it. The only issue was getting enough LEDs, working around the power issues, and setting them up in some manner that looked “official” (and projected enough light in the right direction). Since I was winging this, the most challenging portion was finding some sort of light holder that would work.

Let me share my parts list, then I’ll explain how I put it together and how it works:

I bought 1 of the light kits and ripped the halogen lights out. It turned out removing those halogen bulbs and assemblies was extremely easy, just 1 screw and a rubber cover. I bought 4 of the tri-colored LEDs because my original plan was to put 2 LEDs in each of the driving light cases, one of which would be on each side of the bike. I needed at least 2 resistors (Red/Blue), preferably 3 (also green) per LED so I bought 2 packs of the resistors. Lastly, I saw the 24AWG solid core intercom wire, which was 4 wires bound together — perfect for the LEDs (each LED has 4 legs, 3 leads + 1 common).

It’s been a long time since I’ve done any mount of soldering, so I was slow to get going. The other issue I had is that I had never done much “free soldering” as I call it. By that I mean directly between components. I had always done PCB based soldering (which is much easier). It ended up taking me about an hour and a half to figure out exactly what I wanted to do, test the components, then get my first two LED’s all soldered up. I soldered all 4 LED legs on one side of my intercom wire and then 3 resistors on the other side of the wire (I used about 4′ lengths of wire). After I finished soldering the connections I covered them in hot glue since that does just a fine job water proofing and electrically insulating. I really wanted to get all 4 LEDs done, but I simply didn’t have time, at least not if I wanted to actually USE my project for Halloween.

Once I had the wiring complete, the last piece was to do the programming and to defeat the power issue. Each of the LEDs I was using was rated for 30-50 mAh of current. My recollection was that the Arduino could only provide 50 mAh, leaving me in an interesting position. Luckily, this is an EXTREMELY EASY challenge to solve. I used PWM to alternate between LEDs. I wrote up my script so two LEDs appeared to blink on rapidly 3 times in blue then switched and did the same thing in red. I say “appeared” because of course the two LEDs were never actually on at the same time. One was on for 5 ms then off while the other was on for 5 ms (repeated 10-20 times — depending on the desired length of “flash”).

After all that, it was a matter of putting the Arduino unit (with 9 V battery pack) on my motorcycle; putting the LEDs in place on the driving lights; finally, taping the driving lights in place on top of my rear view mirrors. It wasn’t a perfect setup, but I was very happy with how things turned out for a “last minute” throw together. Before next year, I’d like to make some improvements such as: adding external power so I can run more and brighter LEDs, adding more LEDs in general, add more light locations (rear/side lights along with the existing front), improve the programming so it looks more authentic and lastly, possibly wire the power input into my motorcycle itself.

Additional Information/Media