Halloween is my favorite holiday so I really didn't want to leave the porch light off for two years in a row. However, the pandemic isn't over yet so the candy bowl wasn't going to get refilled unless we could allow for social distancing. Trick-or-treaters walk downhill to get from the sidewalk to our front door so shoving candy into a pipe or sending it in a zipline basket -- the workarounds that many houses used last year -- aren't practical here. Instead, we opted to build a remote-controlled candy bar dispenser.
With one week to go before Halloween we had settled on a mad scientist
theme and built a stockpile of Snickers bars, Kit Kats, Reese's Peanut
Butter Cups, and Hershey's Bars with Almonds. It took several days and quite a few Lego Technic pieces to build
custom, motorized mechanisms for each type of candy that could reliably
spit out exactly one piece at a time.
The little globe on the remote control turns red at startup and then purple after the Bluetooth link is established.
Conveyor belts are versatile but it's much simpler to deal with actual bars. One of the servos is visible in the top-left.
The almonds are not distributed uniformly so a stack will find ways to get stuck unless the bottom bar is tilted forward to minimize the contact patch.
The ends of these flare out just enough to be troublesome.
I wrote a simple MicroPython program for a Mindstorms EV3 that dispensed one piece of candy each time one of the four push buttons were activated. Then I used an nRF52-DK as a Bluetooth receiver and had it respond to remote control commands by toggling two different servos to push the Lego buttons -- each servo could be moved to 0 degrees to push one and 180 degrees to push the other. The girl embedded the servos in a piece of plastic corrugated board and then used zip ties to position the buttons.
Getting this right is harder than it looks but it's faster than implementing a proper UART or I2C interface.
We ran short on time so the nRF52-DK ended up being wired to a breadboard and the candy that was dispensed simply slid down a piece of poster board to a table for collection -- the original concept called for an elaborate ramp a la Rube Goldberg.
The nRF52-DK firmware and wiring was the easy part so it was left until the last minute -- clearly!
A divider provides structure for the mechanical interface between the servos and the Lego buttons and also hides the messy breadboard wiring.
The individual components are fastened to a tote's lid using zip ties.
Adding the tote's lid provides protection.
The remote control itself is actually my favorite part of the build. It is literally just a second nRF52-DK that has been dressed up by the girl to look like something from a mad scientist's lab. She spray painted a shoe box with silver paint and made a wonky "antenna" with an RGB LED stuffed inside a foam ball from the craft store. Then we wired in colorful arcade buttons and some internal RGB LEDs. To finish the build she cut slits in the front so the flashes would be visible when buttons were pressed and affixed a label for each type of candy.
Easily the best looking nRF52-DK I've ever seen.
The project turned out well so we might revisit this concept next year. The best feedback that we received came from a tiny little boy with a sword that yelled "I LOVE IT!" to no one in particular when his candy bar popped out of the machine.
No comments:
Post a Comment