Introduction: Halloween Box Monster
Some of you may have seen my earlier I'ble on creating a Box Monster. But with Halloween so close, I wondered "why not create a Halloween themed Box Monster?" Since I couldn't think of any reason why I shouldn't, here I am with the ever hungry Halloween Box Monster.
This goal of this project is the have the Box Monster with it's glowing green eyes wait for people to get close enough before opening its mouth and displaying "Happy Halloween" with orange LEDs on the inside.
Step 1: What We Need
Naturally, we'll need a few things on hand first before we can make the Halloween themed Box Monster. What I ended up using was:
- For the Box Monster portion
- A small box with a lid (specifically, I used a Uline S-159)
- Box Monster Sticker
- A servo motor and accessories, such as this one
- A small amount of malleable wire, such as soft brass wire
- Wire Cutters
- Screw driver
- Hot glue
- A microcontroller, such as Digilent's chipKIT uC32
- zUNO clips
- jumper wires
- A source of power, such as 4 AA batteries and a battery case, OR
- an appropriate power supply (5V to 9V, at least 1A)
Step 2: Creating the Box Monster
We can first get the Box Monster portion ready by folding up the box and getting the servo motor in place, but not putting on the sticker (otherwise you'll have to cut the sticker to cut out the eye holes) by following the directions here.
Then without peeling off the sticker backing we can figure out where the eyes will be located on the box lid and carefully use a knife or scissors to cut out holes for where the eyes are located. Exact locations are hard to give since it depends where you place the sticker, but the top of each eye will be located about 8 centimeters from the crease/hinge where the lid is attached to the rest of the box. The far edges of each eye will be located about 5.5 cm from the sides of the lid.
Naturally, this does not have to be a perfectly shaped oval. All you really need is a large enough hole to for the green LEDs to light up most of the eye through the sticker (or a piece of paper with a monster face of your own design).
Step 3: Displaying Happy Halloween With a Plethora of LEDs
I wanted to be able to have the Box Monster display "Happy Halloween" when it opened it's mouth. However, I wanted to have the message be in large bright letters which, unfortunately, none of the screens I had on hand could accomplish.
However, I did have access to a bunch of "yellow" (as the box claims) LEDs, which are conveniently orange for all practical purposes. 14-segment displays are a popular way to display all of the "Latin" letters and "Western Arabic" numbers, so I figured I could potentially arrange the LEDs in such a way to mimic the arrangement of a 14-segment display.
I quickly realized that individual LEDs simply do not take up the same space as the convenient bar shape that 14-segment displays use. This forced me to use pairs of LEDs as a semi-accurate representation of a bar. To keep a long story short (and to get to the point) I ended up creating a "16-segment" display out of LEDs with the "top" and "bottom" bars consisting of two pairs of LEDs.
The tricky bit, and where the patience comes in, was getting the 16 pairs of LEDs organized on the breadboard so that a single pair of LEDs (either in series or in parallel) would receive a single input on their anodes (effectively claiming a node for themselves on the breadboard) and have their cathode(s) connected to ground, all the while not shorting themselves out on any other LED pair and keeping the 16-segment display fairly compact. I recommend creating the inside of the 16 segment display first and then the outside edges. This will give you the most room for your fingers when arranging all of the pairs of LEDs on the breadboard.
Step 4: Getting the LEDs to Display the Pattern That You Want
In order to display the correct pattern of LEDs to mimic a letter in "Happy Halloween", I took advantage of using 8-bit SIPO shift registers. These ICs allow me to give them an 8 bit input and have the 8 bits be individually displayed on the 8 outputs.
Knowing this, you can assign the pairs of LEDs in the "top" and "bottom" half of the 16-segment display to individual outputs on the two shift registers. After making these connections, I figured out what pairs of LEDs would need to be lit up in order to display the desired letter and determined the 8 bit binary (and subsequently decimal value) I would need to send to the two shift registers for each letter.
In terms of connecting to the microcontroller, I connected the SER, RCLK, SRCLK, and SRCLR (with the over-bar) to digital pins on the microcontroller. Personally, I used digital pins 34, 36, 38, and 40, respectively, for the shift register attached to the top half of the 16-segment display and pins 26, 28, 30, and 32 for the shift register associated with the bottom half of the 16-segment display.
The Vcc of both shift registers was attached to a 5V rail and both the GND and OE (with the over-bar) were attached to a ground rail. 5V was used instead of 3.3V because two LEDs are to receive a signal from each output, and the combined voltage drop across the two LEDs is above 3.3V (so the LEDs would not light up) but below 5V.
Step 5: Glowing Green Eyes
Since we just talked about most of the LEDs, we may as well finish out the rest of the LEDs that are involved. These last two LEDs are going to light up the eyes of the Box Monster sticker through the holes that we cut out in the box earlier. I chose green LEDs purely because I like green and they were the brightest LEDs that I had available at the time, but you could definitely chose a different color if you wanted to.
On my breadboard, I positioned the LEDs in such a way, with their cathodes attached to the ground rail, so that when the box is closed, the light from the LEDs would shine upward right onto the eyes. This takes a bit of tweaking to get just the right angle, but it's super cool when you get it just right. I attached the anodes of the two LEDs to the digital pins 6 and 7 for the left and right eyes, respectively, so that I could turn the eyes on and off when I wanted to through code by digitally writing pins 6 and 7 HIGH or LOW.
Step 6: Incorporating Distance Detection
There are multiple ways that you can detect if an object is near you, but sonar is a great way to detect something in a certain direction. I used Digilent's PmodMAXSONAR as my sonar sensor. This peripheral module is able to accurate detect an object in front of it between 6 inches and a bit over 20 feet.
In terms of the Box Monster, I used this Pmod in order to figure out when an object, namely a person, is within 7 feet of the Box Monster. Once the Pmod detects that a person is within that distance, you can have the microcontroller turn off the glowing eyes (since they're super bright) and tell the servo motor to open the lid of the box and display the letters in "Happy Halloween".
After "Happy Halloween" has been displayed, you can have the MAXSONAR check to see if there is still an object within 7 feet of it. If there is, you can display the "Happy Halloween" message again. If there is not, the microcontroller can stop displaying the message and close the box lid again.
I used a 4x2x2 pin MTE cable to connect the Vcc pin on the Pmod to a 3.3V rail on the breadboard, the ground pin to a ground rail, and the PW pin to a pulse-width modulation pin on the chipKIT uC32, specifically pin 9. I then taped the PmodMAXSONAR to the small indentation on my box so that it was pointing out in front of the Box Monster.
Step 7: Final Thoughts
You can check out the Halloween Box Monster in action in the YouTube video below, with the code that I used for the chipKIT board available in the text file at the end of this step.
Feel free to ask me any questions that you may have and I will do my best to answer them.
If you would to get the box and sticker that I used, give us a comment on the Digilent Blog for more details. Check out what other cool projects and other things Digilent is up to at the Digilent Blog!