When I was a kid, each Halloween our neighbor Robert would create a "magical machine" that would allow kids to select one of five types of candy they wanted using a Morse code key hooked up to a buzzer. After the desired treat number was entered, a light bulb over the selection would illuminate and the candy bar would come flying out of a chute. The premise of “The Machine” was that it was fully automatic (imagine a box about the size of a case of bottled beer sitting on a table with a curtain strewn up behind it), and he did a great job keeping the story going year after year.
As Robert got older, the responsibility for the Machine was bequeathed to me. It was then I learned the truth about the man behind the curtain, who had to listen carefully to count the Morse code beeps, connect the wires to the right light bulb, and send the candy down the chute. Ever since that discovery, I’ve wanted to make the real, fully automatic machine.
Now that my kids are about the age I was when I learned about The Machine, I decided it was time. This project was a fun change from my day job of working with our customers' prototypes, allowing me to return to my roots and stand in their shoes.
Originally, our plan was to make The Machine work with no software, which we would circle around to next year. However, this changed quickly when we decided it was easier to use stepper motors rather than dealing with brushed motors and gear boxes. Our first task was figuring out the material handling for the candy. We landed on a design which used 1.5” PBC tubes arranged like a pipe organ with an actuator wheel made out of parts of a flat brush from McMaster Carr wrapped around a wooden dowel.
For the EE side, we purchased an Arduino Leonardo from Adafruit. They have amazing libraries and resources to help get you rolling. From previous projects, we had a bunch of SparkFun prototyping boards, and enjoyed reading their detailed tutorials on various EE items.
From here, we built a proof of concept, with one candy channel, and were able to prove out the mechanism. In a few minutes we were able to get the stepper spinning when a button was pressed, accompanied by flashing LEDs. A task for next year is to close the loop and use a sensor to detect when the candy has been vended.
Feeling pretty good about the approach, we created a “roadkill” which had all of the EE brain spinning free motors to prove out the SW. Daniel Ozick, who did much of the code for the original Roombas, was invaluable in helping me untangle my code and making it efficient and scalable so we can add in additional candy channels next year if we want to go that route. We decided to add in a second processor to handle the LED strip, and created a simple communication scheme so they could talk to each other.
The last couple of days have been a sprint to the finish before Halloween - nobody cares about a Halloween Machine on November 1st! We’ve got her working (check out the video here). We're looking forward to Trick or Treating and introducing a new generation to "The Machine."