Motion Sensor Candy Dispenser
by kennednu in Circuits > Raspberry Pi
309 Views, 0 Favorites, 0 Comments
Motion Sensor Candy Dispenser
I made an automated candy dispenser that you can easily keep on a shelf/desk. There's 3 tubes that hold 3 separate round shaped candies, and when the proximity sensor picks up something near it, a micro servo lifts the block in the tube and dispenses candy. There's a slide potentiometer on the side that lets the user select which candy they want and also has an option for a random candy to be dispensed.
Supplies
- Prusa Mini 3D Printer
- PLA 3D printing filament
- Laser Cutter
- 32" x 20" of 1/8" Baltic Birch
- Solder Station and Solder
- Wood glue
- Super Glue
- Hot Glue Gun
- Duct packing tape
- Raspberry Pi Pico W
- Monochrome 1.3" 128x64 OLED graphic display - STEMMA QT / Qwiic
- Adafruit APDS9960 Proximity, Light, RGB, and Gesture Sensor - STEMMA QT / Qwiic
- 3 micro servos
- Slide Potentiometer
- 3 Small Alligator Clip to Male Jumper Wire Bundle - 12 Pieces
- Male to Male Header Jumper Wires
- Stemma QT Wire
- Wireless Charger
- Micro USB Cord
- Candy
Laser Cut and 3D Print the Box, Tubes, and Stands
First the parts of the dispenser need to be created. There are 3 parts to the tubes, all 3D printed: the main straightaway portion, a bend, and a funnel, to make it easy for the candy to be inserted. I created the files in tinkercad. There is also a stand that holds the servo, keeping it at the correct angle. The box and wing is laser cut using the baltic birch, and was designed using MakerCase and then finished in illustrator.
Put Together Box and Tubes and Place Tubes in Correct Spot
The box is glued together using wood glue. Let the box sit for 24 hours to make sure it is fully kept together. Then insert the tube through the front of the box through the back hole, and then super glue the bend, and then funnel to it as well. Do this for all 3 tubes.
Solder OLED Screen
Using the male-to-male header pins, solder 5 into the OLED screen to make the build more permanent. The wiring scheme can be found here. Solder headers to the 3.3V, GND, RST, Clock, and Data pins.
Put Screen, Proximity Sensor, Potentiometer and Servos in Place
The screen and proximity sensor can be taped into place using the duct tape or any other strong tape, being placed in the holes cut out for them. The screen should be to the left of the procmity sensor. The slide potnetiometer can be superglued into the hole on the side. Place the side with the 1 and 2 pin at the top to make sure it is in the right direction. For the servos, first attach the wings to the blade of the servo, such that the wing is flat pointed left when the servo is at 180 degrees. Then find the spot to the right of the tube where the blade is correctly in the slot and angled the right way. Superglue the servo into place in the stand and then the stand to the bottom of the box.
Wire Up the Pico W
The most difficult part is wiring the pico. All three servos have the same wiring, black to GND, red to VOUT, and yellow to a GP pin. The Reese's servo goes to GP15, Skittles to GP16, and M&Ms to GP17. For the slide potentiometer. 1 goes to GND, 2 goes to GP28, and 3 goes to 3.3V. The OLED Screen and Proximity Sensor both are I2C, and are wired the same. Red goes to 3.3V, black goes to GND, blue/DATA to GP4, and yellow/CLK to GP5. The OLED screen has a fifth wire, RST, which goes to GP6.
Download Code
If you are new to the Pico W, follow this video to learn how to set it up. Download the code onto the Pico. You can change the time between the proximity sensor catching a close object and dispensing the candy, and if different candy is inserted you can change the name of it presented on the screen as well.
Downloads
Enter Your Candy and Dispense
Now just plug the Pico into your power source, insert the candy in the top, and get ready to make your friends very happy!