Refurbishing a Mail Slot and Doobell
One Second Services

Candy or Death: The Automatic Halloween Candy Dispenser

Let's start with a word problem. Assume you live in a busy trick-or-treating neighborhood and that, on average, a group of four rings your doorbell every minute and takes 1/2 oz of candy per person. If you leave a bowl full of 2 lbs candy on your front step, how much time will elapse before it will all be gone?

Answer: It's a trick question. Given that that the NIST's strontium lattice clock, the most precise clock in the world, is only capable of measuring time in femtoseconds, nobody knows how long it takes. Humanity has no device capable of measuring the infinitesimal amount of time it takes for unattended candy to disappear from a doorstep on Halloween.

To work around this problem, I decided to build a device to hand out candy on Halloween in a more...civilized...manner.

The first thing was that it had to be a game. This is Halloween, after all, it's supposed to be fun. And I didn't want to just have people walk up and push a button and bunch of times and clean out my candy supply. So instead of just a machine that hands out candy, I built a game. Dinner and show, if you like. I call it "Candy Or Death!"


In case you're wondering, it always lands on "Candy" (I know, it's rigged. Working on the death ray for next year). Here's a view during the day (without the sign):

Daytime view

The Parts

Pics or It Didn't Happen

Here's an album of all of my build pics.

The Mechanics

It all started with the cereal dispenser. I ordered that first and designed around it. I bought a moderately large bag of Starburst candy, dumped them in, and tried to see how much force it would take to get them to dispense. Seemed ok, but it turns out my initial tests were way off (more on that later).

Still unsure about how this exactly would work, I built the frame first. I had decided that I wanted this device to sit in the window that faces onto my front porch. I could use the window to hold the machine in place, and put a back-lit sign up behind the glass.

Laying things out

To make the slide for the candy, I used some old aluminum gutter that I had, and I ordered plastic stacking bin to catch the candy at the bottom.

Fitting to the window Candy slide and catcher

I made sure to countersink the screws on the bottom of the platform to ensure that I didn't scratch up my window sils. Other than that, building the frame was pretty straightforward. Chiseling down the post to hold the dispenser bracket was pretty time consuming though.

The Electronics

The brains of the system is an Arduino Uno R3. If you've ever used an Arduino before, you can guess why I chose it. Simple to program, tons of examples and addons, and relatively cheap compared to most of the other options out there.

In contrast to most electric motors, a stepper motor is capable of precise, high-torque movement, which was exactly what I needed. After a bit of research, it seemed like using the same stepper motors used in a RepRap would mean cheap and easy access to parts. So I ordered a motor, a timing belt, and some pulleys to transfer the torque of the motor and give me a better gear ratio. I also ordered a 5/16" diameter plastic rod that I used to replace the axle and handle of the cereal dispenser.

Because I was trying to use RepRap parts for the motor and pulleys, I originally started with a lower gear ratio (1.8:1) because the largest 8mm bore pulley I could find only had 36 teeth. Unfortunately, despite my earlier tests, this wasn't enough torque. The machine quickly jammed after only a few minutes of use, and the timing belt would start to slip. After that, I found an 80 tooth pulley, which gave me a 4:1 gear ratio, which performed much better.

I was scrounging around for a way to quickly connect and disconnect the wiring for the sign to the main circuit, and came up with using an old RJ-11 (telephone) connector, which worked out great. If I had it to do over again, though, I would have used RJ-45 so I could have more options for lights in sign, so that's what I've included in the parts list.

The Software

You can find the source on Github. If you're not familar with Arduino and the suite of tools for programming it, you can learn more here.

The only library I'm using here is the AdaFruit motor shield library. This library (and the tutorial that AdaFruit provides) makes operating this stepper motor so easy, I basically got it working on the first try.

The Candy

I wound up buying almost 10 lbs of candy. A huge bag of Starburst, and another huge bag of 5lbs Jolly Ranchers. Of all the candy I tested, the Jolly Ranchers worked in the machine best. I just added the Starburst for variety.

The Result

Here's a pic of me running 10 lbs of candy through the machine as a torture test

And this video shows the machine from behind as its running.


Feed You can follow this conversation by subscribing to the comment feed for this post.

The comments to this entry are closed.