Motion Sensor Candy Dispenser

by kennednu in Circuits > Raspberry Pi

309 Views, 0 Favorites, 0 Comments

Motion Sensor Candy Dispenser

IMG_7807.jpeg

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

Laser Cut and 3D Print the Box, Tubes, and Stands

IMG_7790.jpeg
IMG_7780.jpeg
IMG_7779.jpeg
IMG_7778.jpeg
IMG_7788.jpeg

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

IMG_7811.jpeg

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

IMG_7815.jpeg

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

IMG_7812.jpeg
IMG_7813.jpeg

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.

Enter Your Candy and Dispense

Motion Sensor Automated Candy Dispenser

Now just plug the Pico into your power source, insert the candy in the top, and get ready to make your friends very happy!