Intro: Automated Halloween Candy Tumbler / Dispenser
Sadly, we are never home to hand out candy on Halloween. In the past, we would leave out a bowl of candy, perhaps with a sign saying "please take only one". But that is less than ideal, obviously. It invites abuse, and is somewhat lame.
I decided to tackle this important problem using technology. I experimented with some of the other candy dispenser designs out there, but didn't find one that met all my needs. In particular, since it would need to work entirely unattended all evening, it would need a large capacity, and it would have to be 100% resistant to candy jams. Also I wanted it to work with an assortment of packaged candies, rather than just dispensing gum balls for example.
I finally settled on this design, which seems to be pretty bulletproof. It's just a big plastic drum with some holes on the side, which rotates around when activated, causing candy to fall out into a candy chute. The tumbling motion naturally prevents candy jams from forming.
The drum, or tumbler, is activated by an PIR motion sensor, and controlled with an Arduino Uno board. It was cobbled together almost entirely of stuff I had lying around the garage. It isn't pretty, but it is battle tested. It performed flawlessly this last Halloween, operating completely unattended for three hours of exposure to real live trick-or-treaters, without jamming or breaking down.
In addition to performing it's primary function of dispensing candy, it also provides entertainment. The noise and spectacle of tumbling candy made it a hit with the kids. It was voted the best candy system on our block.
Step 1: Materials and Tools.
1. The container. I used some plastic bulk food container with a capacity of a little under 4 gallons. You don't want the container to be completely filled, so the candy has room to tumble and churn. Still, that leaves you with about three gallons of candy capacity, which is pretty good. You'll want to cut out a nice sturdy lid for the container.
2. The axle. Threaded rod, about 3/8" diameter, about two feet long, depending on the size of your drum. Various nuts and washers will be needed to fix things to the axle. Some metal tubing for bushings.
3. The frame. A wood base and two posts. Size depending on the size of your container. Random wood scraps. Screws. My base was plywood about 2 foot by 1 foot. Posts about 15 inches high, 2x6.
4. The drive mechanism. I used an old Ryobi cordless drill, converted to run off of 12V external power leads. A 15 inch wheel from a child's bike was used as a drive reduction mechanism.
5. Power. I used a 12V 5ah SLA battery to power everything.
6. Electronics. Arduino Uno, SainSmart relay, PIR sensor, assorted wiring, jumper cables, connectors etc.
7. Candy chute. Some metal gutter or ducting material.
You'll need your basic saw, drill, wrenches, maybe a soldering iron.
Step 2: Prepare the Frame.
You need a base, and two posts to support the tumbler. You want the tumbler to be suspended above the base with enough room for the candy chute below. My posts were 15 inches high with the hole drilled about an inch from the top. The posts should be far enough apart to accommodate the container, with several inches extra to work with. My container was 14 inches in length, and I left an inch of space on either end.
I drilled the posts with a 1/2 inch drill, then cut some metal tubing and epoxied in the holes as a bushing. Metal tubing should stick out a little from the wood, to keep hardware from rubbing against wood. Mount the posts on the base using good sized wood screws. Use threaded rod to make sure the holes are well aligned and rod can rotate without binding. If not, make adjustments.
Step 3: Prepare the Container.
Drill a hole at the bottom of the container, in the very center, just large enough for the threaded rod to pass through. Drill a hole through the center of the container's lid. If your container doesn't already have a sturdy lid, cut one out of wood, then drill some screw holes in the side to attach the lid later. Make some holes where you want the candy to exit. This should be up near the lid. The holes will also be useful for sticking a wrench in to hold the nut when you fix the lid to the axle. Leave these a little on the small side for now, it's easier to make them bigger than make them smaller. You will adjust the size later to control the rate of candy.
Cut out a largish hole on the side for loading. Save the cut out piece. This will then be taped shut during operation.
Step 4: Mount the Tumbler
Start by attaching the wheel to the threaded rod at one end, using nuts on both sides, lock washers or whatever. Needs to be attached very firmly, must not work loose. Do what you need to do.
Push other end of rod through bushing on first post. Then through the hole on the bottom of the container. Then work a nut down along the threaded rod, to about where you expect the lid to be. Then the rod goes through the center hole of the lid, which you then work down to the nut you previously placed. Add a top nut before putting the rod through the second bushing, Get lid in place, use wrenches to tighten top and bottom nuts against lid, so it's firmly attached to the threaded rod. This will need to deliver all the torque from the rod to the drum. Finally, add some sort of locking nut at the terminal end of the threaded rod to keep the whole thing in place. It should rotate freely without much slippage fore and aft. Add washers or whatnot as needed.
Looking back, an easier method would probably have been to assemble everything on the axle first, then have the bushings rest on the tops of the posts, then expoxy/fix the bushings in place. Whatever works.
Step 5: Mount the Drill
The collar of the drill presses against the tire, as a primitive sort of gearing mechanism. You want the drill to be held snug against the tire to deliver power. Since this was an old drill I wasn't using any more, I felt no qualms about simply drilling through and bolting it's bottom to the base, then using a bungee wrapped around the post to make sure firm pressure was maintained. You can hook up the drill to power now and test manually. You will adjust the speed later.
There must be a better way of driving the thing, with belts and pulleys or whatnot, but this worked.
Step 6: Mount the Candy Chute
Use a piece of scrap wood, to provide an anchor for mounting the candy chute. Make sure the angle is steep enough so candy flows freely.
Step 7: Wire Everything Together.
The 12V battery powers both the drill and the arduino. No high voltage needed anywhere, which gives peace of mind. Power to the drill goes through the SainSmart relay.
I found it convenient to add separate on/off switches to both the drill and Arduino for various purposes. I also added an LED to indicate when the system was armed.
Use 5V output from Arduino to power PIR sensor and SainSmart relay. Signal pin from PIR to arduino input pin, arduino out pin to SainSmart signal pin. I took about six feet of telephone line and soldered jumpers to three of the four wires (the only soldering I did on this project) so that I had freedom in where I placed the PIR sensor. I duck-taped the sensor to a nearby wall to activate when people approached the machine.
Step 8: Tuning
I used a cable tie wrapped around the trigger of the drill to adjust speed. Even with the speed reduction due to the bike wheel, if the drill is at full speed the tumbler will spin too fast, and candy will be centrifuged and flung in every direction. Ask me how I know. You want it slow enough that the candy tumbles nicely, but not so slow that it stalls. Gradually pull the cable tie tighter until you get it right. I ended up with the drum spinning at about 10-12 RPM.
Experiment with exit hole size and shape. Load it with an assortment of candies you intend to use. Obviously, bigger holes means candy comes out faster. Some package shapes are more problematic than others. It's easier to widen the holes later than to un-widen them.
To keep candy flowing towards the exits, you'll want to bottom side of the drum inclined about 5 or 10 degrees, because, you know, gravity. The natural taper of my container was not enough, so I ended up just shimming the entire contraption.
Step 9: Front End / Software
The front end facade was pretty rushed. I didn't want all the workings exposed to little fingers, so I just cut out a big piece of cardboard to cover up the front, with a hole for the candy chute. You don't want to cover up everything, because people enjoy watching the candy tumble around.
The controller programming was very simple. Downloaded an arduino demo sketch for PIR sensors, and added a couple lines of code. When PIR is triggered, activate the tumbler for 10 seconds or so, then leave about 5 seconds dead time before re-arming the system. The dead time was to encourage people to mosey after getting their candy, but not too long in case not enough candy came out on the first try.
All in all, a pretty robust basic design, with plenty of room for refinement. Thanks for watching.