Wrapped Candy Dispenser

by jimmy.bilodeau in Living > Halloween

101 Views, 1 Favorites, 0 Comments

Wrapped Candy Dispenser

20241109_102933.jpg
Candy_Dispenser_1.png
Candy_Dispenser_2.png

This wrapped candy dispenser provides an interactive experience for your tick-or-treaters at Halloween!

It can fit many different snack-sized candies like Kit-Kat, Reese's Cup, Snickers, Twix, etc... I wanted to create something that is versatile and isn't going to limit the different candies I may give out.

This build requires 3D printing, soldering, and laser cutting (may be replaced with standard woodworking techniques). It has some complexity, but I will hopefully give you enough direction to make it simple to build your own!

Supplies

3D Printed Parts:

  1. 2kg PLA filament, or similar

Enclosure Box:

  1. 1/8" (3mm) Birch Plywood, or similar

Electrical:

  1. Arduino Uno R3
  2. 9V or 12V Power Supply, or similar
  3. Adafruit Motor Shield v2
  4. Nema 17 Stepper Motor, 12V, 350mA, or similar
  5. 100mm LED Button, or similar
  6. 26 AWG Wire (other wire gauges usable)

Metal:

  1. 6mm Aluminum Rod (300mm needed), or similar (note, this may be able to be replaced with a 3D printed rod)

Hardware/Other:

  1. M3 x 12mm Screws, Qty: 39 (McMaster-Carr 91292A114 or similar)
  2. M3 Washers, Qty: 4 (McMaster-Carr 93475A210 or similar)
  3. M3 Nuts, Qty: 5 (McMaster-Carr 90591A250 or similar)
  4. M3 Press-In Inserts, Qty: 26, (McMaster-Carr 94510A030 or similar) heat-set inserts would also work
  5. Wood Glue
  6. Instant Adhesive

Tools Needed:

  1. 3D Printer
  2. Laser Cutter
  3. Soldering Iron
  4. Wire Stripper/Cutter
  5. M3 Tap
  6. 2.5mm Hex Key (Allen Wrench)
  7. 1/2" Drill Bit

Optional:

  1. Shield-Stacking Headers
  2. Panel-Mount DC Jack
  3. Female DC Jack to Terminal Block
  4. In-line power switch
  5. Spade Terminals
  6. Ferrule Crimping Kit

3D Print Plastic Parts

3D_Printing.jpg

First, 3D print the following parts from PLA, or any other plastic:

  1. Candy_Dispenser_Conveyer_Link.stl, Qty: 30
  2. Candy_Dispenser_Conveyer_Pin.stl, Qty: 30
  3. Candy_Dispenser_Conveyer_Pin_Clip.stl, Qty: 30
  4. Candy_Dispenser_Conveyer_Tray.stl, Qty: 15
  5. Candy_Dispenser_Conveyer_Tray_Clip.stl, Qty: 15
  6. Candy_Dispenser_Conveyer_Sprocket_Only.stl, Qty: 4
  7. Candy_Dispenser_Conveyer_Sprocket_Spacer.stl, Qty: 2
  8. Candy_Dispenser_Frame.stl, Qty: 1
  9. Candy_Dispenser_Frame_Side_Right.stl, Qty: 1
  10. Candy_Dispenser_Frame_Side_Left.stl, Qty: 1
  11. Candy_Dispenser_Mount.stl, Qty: 1
  12. Candy_Dispenser_Shoot.stl, Qty: 1
  13. Candy_Dispenser_Outlet.stl, Qty: 1
  14. Candy_Dispenser_Front_Face.stl, Qty: 1
  15. Candy_Dispenser_Enclosure_Corner, Qty: 8
  16. Candy_Dispenser_Gear_6mm_Bore, Qty: 1
  17. Candy_Dispenser_Gear_5mm_Bore, Qty: 1

Note, the Frame and Frame Sides are large and may require splitting into multiple parts depending on your 3D printer size. These will fit diagonally on a 300mm x 300mm plate.

Prepare the Enclosure

Front_Top_Rear_Botton_Enclosure_Parts.jpg

Next, laser-cut the following parts. Each part fits within 12"x12".

  1. Enclosure_Top, Qty: 1
  2. Enclosure_Bottom, Qty: 1
  3. Enclosure_Side, Qty: 2
  4. Enclosure_Front, Qty: 1
  5. Enclosure_Rear, Qty: 1
  6. Front_Face, Qty: 1


Note, laser-cutting is not required; a similar enclosure can be made using standard woodworking tools or 3D printing.

The Front Face has a freely found vector file for the Halloween decoration scene. Feel free to replace this with whatever you want!

Prepare the Electronics

Motor_Wiring_Shield.jpg
Button_Wiring_Pinout_Annotated.jpg
Button_Wiring_Shield_1.jpg
Button_Wiring_Shield_2.jpg
Panel_Mount_DC_Connector_Pinout.jpg

Adafruit Motor Shield Preparation

  1. Solder the included headers in the Adafruit Arduino Motor Shield
  2. The Arduino Motor Shield v2 by Adafruit is delivered without headers installed for connecting to the Arduino. So, the first step is to solder the headers to the shield per the following instructions: Link
  3. Optionally, you may use Shield Stacking Headers to allow for stacking additional shields for future projects. Link
  4. Place the Power Jumper on the motor shield.
  5. This will allow the the Arduino Uno and Motor to be powered by the same power supply.

DC Power Connector

The Motor Shield has an input for power, a screw terminal with a positive and negative contacts. A 2.1mm barrel connector for the Power Supply to connect needs to be connected to these terminals to power the motor shield and Arduino (there are other options for powering these; refer to the Adafruit website for the motor shield). I will explain The connector I made, which is uses a board-mount barrel connector that I had on hand, as well as a preferred panel-mount connector.

Board-Mount Connector

  1. Cut two 26 AWG wires to 6 inch length.
  2. Note, other wire gauges may be used; I had 26 AWG wire handy and used that. Certainly 22 or 18 AWG wires would also work.
  3. Using two different wires colors (such as red for positive and black for negative) will help ensure the correct wires go to the correct locations on the motor shield, but not required.
  4. Strip approximately 1/8" of the wire jackets away from each end of each wire.
  5. Solder the two wires to the DC barrel connector (link) leads.
  6. The back contact is positive and front contact is ground.

Panel-Mount Connector

  1. Cut two 26 AWG wires to 6 inch length.
  2. Note, other wire gauges may be used; I had 26 AWG wire handy and used that. Certainly 22 or 18 AWG wires would also work.
  3. Using two different wires colors (such as red for positive and black for negative) will help ensure the correct wires go to the correct locations on the motor shield, but not required.
  4. Strip approximately 1/8" of the wire jackets away from each end of each wire.
  5. Solder the two wires to the DC barrel connector. Refer to the Panel_Mount_DC_Connector_Pinout picture for pinout.
  6. Only one of the two negative terminals need to be connected.

Nema 17 Stepper Motor Preparation

  1. Strip approximately 1/8" of the wire jackets away from each Stepper Motor.
  2. Optionally, crimp ferrules onto the exposed wire leads using a ferrule crimping tool.
  3. This provides a more robust connection to the screw-down terminals on the motor shield. It is completely optional; the wires can be inserted directly into the motor field terminals.

100mm Button Preparation

  1. Remove the switch from the back of the 100mm button.
  2. Cut four 26 AWG wires to 6 inch length.
  3. Note, other wire gauges may be used; I had 26 AWG wire handy and used that. Certainly 28, 22, 18 AWG wires would also work.
  4. Using four different wires colors will help ensure the correct wires go to the correct locations on the motor shield, but not required.
  5. Strip approximately 1/8" of the wire jackets away from each end of each wire.
  6. Optionally, crimp spade terminals to one end of each wire with a wire stripping/cutting tool.
  7. Using crimp spade terminals will allow for disconnecting wires from the button.
  8. If spade terminals are not used, solder one wire to each of the 4 spades on the button switch.
  9. Optionally, crimp ferrules onto the exposed wire leads using a ferrule crimping tool.
  10. If the shield stacking headers are used, the ends of the wires will need a male header soldered to the end.
  11. Take of of the header rows that came with the motor shield and cut individual contacts from it.
  12. Solder the short end of the contact to the wire.
  13. Repeat for the 4 wires.
  14. If the shield stacking headers are not used, the ends of the wires will need to be soldered to the shield pins. Refer to picture Button_Wiring_Pinout_Annotated
  15. Solder the wire connected to Switch NO to pin 11 on the shield
  16. Solder the wire connected to Switch GND to one of the GND pins on the shield (next to pin 13 or opposite side, next to the VIN pin)
  17. Solder the wire connected to LED + to pin 13 on the shield
  18. Solder the wire connected to LED - to one of the GND pins on the shield (next to pin 13 or opposite side, next to the VIN pin)

Assemble Electronics

  1. Connector Motor Wires to Motor Shield
  2. The motor shield has a 5-contact terminal block for the motor wires. From right to left, the motor wires go into the terminal block: Red, Yellow, N/A, Green, Gray.
  3. Connect Button Wires to Motor Shield - Refer to picture Button_Wiring_Pinout_Annotated
  4. If the shield stacking headers were used:
  5. Connect Switch NO to pin 11 on the shield
  6. Connect Switch GND to one of the GND pins on the shield (next to pin 13 or opposite side, next to the VIN pin)
  7. Connect LED + to pin 13 on the shield
  8. Connect LED - to one of the GND pins on the shield (next to pin 13 or opposite side, next to the VIN pin)
  9. If the shield stacking headers were not used, the wires are already connected to the motor shield!
  10. Connect the DC Power Connector
  11. Secure the positive lead from the DC power connector to the positive lead of the motor shield terminal (left-side).
  12. Secure the positive lead from the DC power connector to the negative lead of the motor shield terminal (right-side).

Arduino Code

Arduino_Full_Wiring.jpg
USB-A_to_USB-B.jpg
  1. Install the Arduino IDE, if you do not already have it. Link
  2. Install the motor driver libraries needed from Adafruit using the steps described here: Link
  3. Copy the code below into a new Arduino IDE file.
  4. Connect the Arduino Uno via a USB-A to USB-B cable to your PC.
  5. Compile and upload the code to the the Arduino Uno.

Code:

/*

This is a test sketch for the Adafruit assembled Motor Shield for Arduino v2

It won't work with v1.x motor shields! Only for the v2's with built in PWM

control


For use with the Adafruit Motor Shield v2

----> http://www.adafruit.com/products/1438

*/


#include <Adafruit_MotorShield.h>


// Create the motor shield object with the default I2C address

Adafruit_MotorShield AFMS = Adafruit_MotorShield();

// Or, create it with a different I2C address (say for stacking)

// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61);


// Connect a stepper motor with 200 steps per revolution (1.8 degree)

// to motor port #2 (M3 and M4)

Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 2);


void setup() {

 pinMode(11, INPUT_PULLUP); //uses internal pullup resistor for switch button

 pinMode(LED_BUILTIN, OUTPUT);

 Serial.begin(9600);     // set up Serial library at 9600 bps

 while (!Serial);

 Serial.println("Stepper test!");


 if (!AFMS.begin()) {    // create with the default frequency 1.6KHz

 // if (!AFMS.begin(1000)) { // OR with a different frequency, say 1KHz

  Serial.println("Could not find Motor Shield. Check wiring.");

  while (1);

 }

 Serial.println("Motor Shield found.");


 myMotor->setSpeed(30); // 30 rpm is motor speed

}



void loop() {

  //digitalWrite(buttonPin, HIGH);

 

 //read state of switch into a local variable

 int buttonState = digitalRead(11);

 Serial.print(buttonState);


  if (buttonState == LOW) {

   digitalWrite(LED_BUILTIN, LOW); //turn LED off

   Serial.println("Microstep steps");

   myMotor->step(60, BACKWARD, DOUBLE);

   //direction is either FORWARD or BACKWARD 

   // the step type is SINGLE, DOUBLE, INTERLEAVE or MICROSTEP.

   //"Single" means single-coil activation

   //"Double" means 2 coils are activated at once (for higher torque)

   //"Interleave" means that it alternates between single and double

   //to get twice the resolution (but of course its half the speed).

   //"Microstepping" is a method where the coils are PWM'd to create

   //smooth motion between steps.

   delay(3000); //wait for 3 seconds to allow person to grab candy

   //and indicates they should wait to press again. This is optional.

  }

  else {

   digitalWrite (LED_BUILTIN, HIGH); //turn LED on

  }

}

Enclosure Assembly

Front_Top_Rear_Botton_Enclosure_Parts.jpg
Front_Top_Rear_Botton_Enclosure_Taped_for_Gluing.jpg
Gluing_Panels.jpg
Assembled_Main_Enclosure_Frame.jpg
20241109_090131.jpg
3D_Printed_Cartidge_Mount_Placed_Inside_Enclosure.jpg
3D_Printed_Cartridge_Mount_Mounted_Top_Enclosure.jpg
3D_Printed_Shoot_Assembled_to_Mount.jpg
3D_Printed_Front_Panel.jpg
M3_Inserts_Installed_Front_Panel.jpg
Align_Front_Panel_Over_Holes.jpg
Secure_Front_Panel_to_Enclosure_and_Shoot_with_M3_Screws.jpg
Glue_Outlet_to_Front_Panel.jpg

The enclosure is made from laser-cut 1/8" (3mm) birch plywood. To assemble the main enclosure:

  1. Take the front, top, rear, and bottom panels and interlock the edges.
  2. Apply painter's tape, or similar, along all but one of the edges.
  3. Unfold the panels so that they lay flat with the inside of the enclosure panels facing up.
  4. Apply wood glue between the interlocking features on the edges of the panels.
  5. Refold the panels together and tape the un-taped edge so that the box is held together completely.
  6. It may be helpful to use objects, such as scrap wood, to hold the box square. The side panels can also help with this, but you will want to make sure they do not accidentally be glued in place.
  7. Let the wood glue cure for at least 1 hour before handling further.

Corner blocks are added on the sides so that the side panels can be secured with screws and be removable for accessing internal components. One block is added to each corner on each side of the main enclosure. To assemble the corner blocks to the main enclosure:

  1. Take the 8x 3D printed corner blocks and press an M3 insert into one of the holes in each block (total of 8 inserts installed).
  2. Apply adhesive, such as super glue or Gorilla glue, to two faces of the corner block that will be secured to the main enclosure.
  3. Press the corner block into the main enclosure side corner such that the face with the M3 insert faces outward and is in-line with the inner edge of the interlocking features of the side panels. Wait for glue to cure.
  4. Applying hot glue to the block can hold it in place while the adhesive cures.
  5. Perform steps 2 and 3 for the remaining 3 corners on that side and then all 4 corners on the opposite side.

Attach the 3D printed front panel, outlet, shoot, and cartridge mount to the main enclosure. To assemble:

  1. Using 5x M3 x 12mm screws and 5x M3 nuts, secure the 3D printed cartridge mount to the underside of the top panel of the main enclosure.
  2. Place the 3D printed shoot over the outlet of the cartridge mount, inside the enclosure. Ensure the screw bosses on the end align with the holes of the front panel.
  3. Press 4x M3 inserts into the 4 bosses of the 3D printed front panel.
  4. Place the 3D printed front panel against the front panel of the main enclosure such that the 4 screw bosses pass through the 4 holes on the front panel.
  5. Using 4x M3 x 12mm screws, secure the 3D printed shoot to the inside of the main enclosure front panel using the 4x screw bosses of the 3D printed front panel.
  6. The rectangular end of the shoot also must be aligned with the rectangular cartridge mount outlet. These don't require an adhesive to hold together; the fit of the parts keep these tight together.
  7. Adhere the 3D printed outlet to the 3D printed front panel using instant adhesive.
  8. Apply adhesive around the tongue-and-groove around the edges that align these parts.

Conveyer Belt Assembly

Convey_Links_Assembly_1.jpg
Convey_Links_Assembly_2.jpg
Convey_Links_Assembly_Complete.jpg
Conveyer_Tray.jpg
Assembled_Conveyer.jpg

The conveyer belt is made from the 3D printed conveyer links, pins, and clips.

  1. Take two conveyer links, one pin, and 1 clip.
  2. Align the two links so that the top center hole of one link is aligned with the two side holes of the second link. Ensure the links are facing the same side.
  3. Slide a pin through the aligned holes of the links.
  4. The end of the pin has a stepped collar at the end. Press the clip into that step.
  5. Repeat this with all 30 conveyer links. The last links will loop back to the first link, so that it makes a continuous loop. You can wait to connect these until after attaching the trays.

The trays which the candies will sit attach to the conveyer links.

  1. Take one tray and slide the three alignment blocks on the tray into the holes of the link.
  2. Secure the tray to the link by pressing a tray clip over the center block on the back of the link.
  3. Repeat attaching the trays every other link. You could attach one tray in each conveyer link, but you will only fit thin candies.

With that, the convey belt is complete!

Cartridge Assembly

Cut_Rotary_Shafts.jpg
Drill_Pilot_Hole_Rotary_Shafts.jpg
Tap_M3_Threads_Rotary_Shafts.jpg
Right_Side_Cover_Fastened.jpg
Rotary_Shafts_in_Right_Side_Cover.jpg
Conveyer_Assembled_to_Cartridge_Frame.jpg

Rotary shafts

  1. Cut a 110mm long 6mm diameter aluminum rod.
  2. Secure the 110mm shaft using a vice, or similar, with one end facing upward.
  3. Mark the center of the end of the shaft, approximately, with a center punch or similar.
  4. Drill a 12mm deep pilot hole (approximately), with a 2.5mm drill bit.
  5. Tap M3x0.5 threads into the hole.
  6. Flip the shaft to the other side and repeat steps 3-5.
  7. Cut a 125mm long 6mm diameter aluminum rod.
  8. Repeats steps 2-6 with this rod so that there are M3x0.5 threads on both sides of the rod.

Sprockets & Gear

  1. Press the 6mm bore gear onto one end of the 125mm long shaft.
  2. Secure the gear in place with an M3 washer and M3 x 12mm screw.
  3. Slide the 125mm shaft from the outside of the bottom hole of the right side cover of the cartridge frame. It should rotate freely.
  4. Apply instant adhesive onto the shaft on the "inside" of the right side cover (opposite side from the gear).
  5. Press a sprocket over the shaft until it touches the raised boss of the right side cover.
  6. Press the sprocket spacer over the shaft until it touches the sprocket.
  7. Press a second sprocket over the shaft until it touches the spacer.
  8. Spin the sprockets and spacer to spread out the instant adhesive that will bond the sprocket to the shaft.
  9. ENSURE THE TWO SPROCKETS ARE ALIGNED. Otherwise, they may get glued into the wrong position and the conveyer will not move smoothly.
  10. Slide the 110mm shaft into the top hole of the right side cover of the cartridge frame.
  11. Fasten an M3 washer and M3 x 12mm screw to the shaft from the outside (gear-side) of the cover.

Cartridge Assembly

  1. Press an M3 insert into each hole of the 3D printed cartridge frame, on both sides. This requires 16 M3 inserts.
  2. Attach the right side cover of the cartridge using 8x M3 x 12mm screws.
  3. Wrap the assembled conveyer belt assembly around the two sprockets. Ensure the trays face upward on the left side of the cartridge.
  4. Place the left side cover over the two shafts.
  5. Fasten the left side cover of the cartridge using 8x M3 x 12 mm screws.

The cartridge assembly is complete!

Electronics Assembly

Motor_Assembly.jpg
5mm_bore_Gear_Motor_Shaft_Assembly.jpg
Motor_Mounted.jpg
Button_Switch_Mounted.jpg
Assembled_Electronics.jpg
In-Line_Power_Switch.jpg

Assemble the electronics into the enclosure.

  1. Press the 5mm bore gear onto the end of the motor shaft.
  2. Fasten the motor to the 3D printed mount attached to the enclosure frame with 4x M3 x 12 mm screws.
  3. Attach the DC power input connector to the rear of the enclosure with the included connector nut. This will require disconnecting the wires from the Arduino motor shield so that the connector can be mounted from the outside. The nut is placed on the inside wall.
  4. Place the laser-cut front panel onto the 3D printed front face so that the cutout hole is aligned with the enclosure front hole.
  5. Remove the switch from the back of the 100mm button.
  6. Place the 100mm button through the aligned holes.
  7. Fasten the 100mm button to the front of the enclosure using the included threaded nut from the inside of the enclosure.
  8. Reconnect the 100mm button from the inside. It has a bayonet-style connection where rotating the switch when aligned to the back of the button will lock it in place.
  9. Drill a 1/2" hole into the rear panel of the enclosure.
  10. Using the nut included with the DC connector, place the DC connector through the drilled hole and secure it to the rear panel.
  11. Place the Arduino into the enclosure. This can be mounted to the enclosure with double-sided tape or left to sit inside.

At this point, the assembly is ready to test.

  1. Plug in the 9V-12V power supply to a wall outlet.
  2. Connect the barrel plug of the power supply to the DC power input connector on the rear of the enclosure. The device is now powered.
  3. If desired, an in-line switch can be connected between the power supply and DC power connector of the rear enclosure to be able to turn power on or off without disconnecting the power supply from the wall outlet.
  4. Place the cartridge assembly into the enclosure mount, ensuring the gears of the cartridge mount with the gears of the motor.
  5. Press the front button and watch the left side of the cartridge to verify the conveyer moves.

With the electronics complete, and the mechanisms working, the enclosure can be closed.

  1. Using 4x M3 screws, per side, attach the side panels to the main enclosure.

Final Assembly

Candy_Dispenser_Assembled.png
20241103_105235.jpg
20241109_090207.jpg

The candy dispenser is now complete and it is ready to put candy inside! Take your favorite candies and place 1, or more, on each tray of the cartridge. The trays that are "upside-down" will move and push any candies on them over to the other side once they pass over the top, so feel free to fill in both sides.

As an option, you can place some LED lights, like these, behind the front panel so the light flickers behind.

Also, the design was made such that the cartridge can just be lifted out of place and replaced with a second candy-filled cartridge, if desired!

Enjoy!