Dole Out Candy From a Distance with This Dispenser
See how Adam Soileau from e14 Presents created this socially-distanced candy dispenser complete with facial recognition and lights.
The Problem
This year, Halloween will look markedly different compared to previous years. Due to the pandemic, people are encouraged to maintain distance between each other, which will prevent many of the events that occur on the holiday, especially trick-or-treating. To make up for this, Adam Soileau over on element14 created a Socially-Distanced Halloween Candy Dispenser that is able to automatically give out sweets from a distance.
Materials and Hardware
The dispenser consists of several distinct pieces that work in concert to drop candy into the contains of eager trick-or-treaters. First, there is a Raspberry Pi Camera (the NOIR variant) that can gather a live feed of video in front of the box to detect the presence of people. There is an LCD screen at the center that shows information such as how many people are present at any one time. Finally, a NEMA17 stepper motor turns an internal 3D-printed auger to dispense candy, and it's driven by an Adafruit TB6612. All of these components are connected to a Raspberry Pi 4, which acts as the brain for the project.
The remainder of the hardware was fabricated with the help of a 3D printer (for the internal pieces and mounts) and CNC router (for the actual enclosure).
Facial Recognition
The program that controls the dispenser begins by reading an image from the Raspberry Pi NOIR camera and stores it in memory. It's then converted into a grayscale image and run through an OpenCV facial detection algorithm that finds each face and places them into an array. If a face is found, it initializes a counter variable to keep track of how much candy is left to be dispensed.
Dispensing Mechanism
It can be quite difficult to precisely measure and distribute objects that are of an unequal size, as is the case with individually-wrapped pieces of candy. The solution that Soileau was able to come up with was quite clever. Rather than attempt to separate each piece, he design and printed an auger that spins just below the container and pushes it all forward where it can then drop. This has the added benefit of precise control, as a certain number of rotations from the stepper motor equates to a predetermined amount of candy.
Communication with Trick-or-Treaters
Kids coming up to the enclosure might not know what to do at first, so being able to convey that information is vital. That's why Soileau added a blue 16x2 alphanumeric screen that sits front and center on the box. It is controlled with the standard LCD parallel interface, along with the Adafruit character LCD library for simple use. If the Pi has detected that someone is in front of the dispenser but not close enough to the ultrasonic distance sensor, it shows a "Step in front of the dispenser" message, which hopefully guides people how to use it correctly.
Final Thoughts
This socially distant method of handing out Halloween candy is great for times like this. It allows for physical interactions to be almost non-existent, along with some additional benefits, such as automatic instructions and removing the need to remain in the cold for hours on end.
Embedded Software Engineer II @ Amazon's Project Kuiper. Contact me for product reviews or custom project requests.