Introduction: Firetruck Costume
Like every eight year old boy our son is enamored with firemen and firetrucks. I can't really blame him because I am too! We built him a firetruck costume this year for Halloween 2015. In this Instructable I will reverse engineer how we built this costume. I will primarily focus on the tech behind the construction rather than how to build the truck itself.
Step 1: Construction
Like I mentioned, I will not go into too much detail on how this was built but let me know if more info is needed on this part of the project. Our goal was to build a base around Cam's powered wheelchair that we could easily put the truck on and off without the need for tools or parts. On the bottom of his chair he has four eye holes for tie downs so Cam and I created the base to fit four short dowels through these holes to hold it in place. Then we fit the frame of the firetruck around this base. It slipped right over top the base and stayed secure. The front and sides of the firetruck were all one piece and then the back end locked into place after the main body was on. This made it really easy to put it together and then take it apart when finished. Added a quick 'ladder' and toe strap/hose to the back of the firetruck for effect.
Step 2: Arduino for Lights and RPi for Sound
Of course, we had to put lights and a siren on this truck....obviously. When we first set this up I thought we could get the sound and lights to both be controlled from the Arduino. I could not figure out how to get the Arduino play sounds other than just a just a buzzing from the Piezo speaker. Therefore, we decided just to use a Raspberry Pi as well to play an MP3 file. KISS principle - Keep It Simple Silly!
For the buttons we fashioned a little lap box with two arcade style momentary switch buttons. One button was connected to the RPi to start the siren and the other was connected to the Arduino to start the light bar pattern.
I will go into more details on how to setup the Arduino and RPi in the following steps.
Step 3: Lights!
I wanted to add a lot more lights but at some point you have to say 'hey, it's just Halloween'. Cam thought what we had was awesome so it was good for me. To drive the lights we used an Arduino Uno. We setup two sets of two lights on the front of the truck with two 'domes' per set. We ran this from the Arduino to the first light and then daisy chained this to the second light in the set. This allowed us to program two different light patters so the lights could blink opposite each other and alternate the pattern.
For the lights we just used two (or three in one case) red LEDs. We put these LEDs on a prototype circuit board and then twisted all the anodes and cathodes together with the wires running to the Arduino. If I was doing it for real I should have soldered these but like I said....it was just Halloween. It looked ugly behind the scenes but worked well. Then we screwed this prototype board under plastic cups which poked through the top of the firetruck. At first you could clearly see the light all coming from the center of the cup so we added a piece of foam wrapping to defuse the light and make the entire dome glow.
Step 4: The Code Behind the Lights
Attached is a text file with the code for the Arduino. This is not the prettiest code and looking back I should have setup functions for each sequence and then called this X number of times. I'm not a programmer (obviously) and I had to set this up in one evening. If you look at the code don't be overwhelmed by the length, it is very simple once you break it down.
In the "VOID SETUP" section I am just defining the PINs that I use and declaring them for output. This section runs one time when the Arduino first powers on. The real magic happens in the "VOID LOOP". This section will keep running until the Arduino is reset. The code will wait until the button is pressed before playing the light sequence. Then I am first turning on the first set of lights (LED, HIGH) and then delaying for 60ms before turning this set of LEDs off again (LED, LOW). Then I do the same thing with the second set of lights (LED2). Easy! I just copied and pasted this 2 million times and changed the delay for different light patterns.
digitalWrite(LED, HIGH); // Turn on light set #1<br> delay(60); // Hold for X milliseconds digitalWrite(LED, LOW); // Turn off light set #1 delay(60); // Hold for X milliseconds digitalWrite(LED2, HIGH); // Turn on light set #2 delay(60); // Hold for X milliseconds digitalWrite(LED2, LOW); // Turn off light set #2 delay(60); // Hold for X milliseconds</p>
Step 5: Now for the Sound
This turned out to be the easy part. I just created the attached Phython script on the Raspberry Pi to play an MP3 file when a button was pushed. The button was connected to GPIO PIN 18 and the Ground. After I had this script working correctly I configured the RPi to automatically run the script as soon as it powered on. I used an external battery pack to power the computer while traveling around and a portable speaker to play the audio file.
Step 6: Finished Product
In the end this turned out very well. I always want to keep over engineering but sometimes you just have to know when to stop. Cam loved it and had a great time. We visited the fire station and got to meet some real firefighters.
I hope this helps someone on their next project. It was just a blast to have fun making this with my son.