Introduction: Candy Bot

This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida (www.makecourse.com)

The Candy Bot is a small, desktop-sized candy dispenser that uses an Arduino Uno, LCD Screen, Distance Sensor, and Stepper Motor to dispense small amounts of candy without the need to press any buttons.

The machine functions by dispensing a serving of candy when a hand or cup is placed underneath the overhang while displaying status messages on the LCD screen.

Supplies

Arduino Uno

I2C 16x2 LCD Screen

Ultrasonic Distance Sensor Module HC-SR04

ULN2003 5V Stepper Motor + ULN2003 Driver Board for Arduino

3D-Printer Access and Filament

USB A to B Cable

Various Jumper Wires

Female to Male Jumper Wires

Solderless Breadboard Power Rail

Super Glue

Electrical Tape

Sandpaper (various grit)

Rust-Oleum Chalked Paint/Primer Mix

Various Acrylic Paints for Decoration (Personal Preference)

Blue Painters Tape

Step 1: 3D Modeling

This project is based mainly on 3D models created using Autodesk Inventor. There are a total of 5 prints necessary to complete this project:

1) Base Section - This print acts as the foundation of the project. It includes a cavity to hold the Arduino Board, a hole to secure the power cable, and pegs to fasten the base to the upper section.

2) Upper Section - This print is where all of the components are mounted. The LCD screen will fit snugly into the front hole, the distance sensor will fit into the two holes facing downward, and the stepper motor will lock into the main cavity holes where it will connect with the rotor. The peg holes are used to mount the Base Section to the Upper Section and can be modified to include a mount for the Lid as well.

3) Rotor - This print is what is attached to the stepper motor and used to dispense the candy. Its curved blade edges are used to prevent the system from jamming while providing a smooth dispense.

4) Lid - This print is used to close the Upper Section off and provides a shoot to hold candy for future dispensing.

5) Cap - This small print is used to prevent dust or debris from entering into the container on the lid.

When designing these components, I wanted to make sure everything could be self-contained so the cavities needed to be large enough to hold all of the electrical components as well as dispense candy. The main dimensions are roughly 5x5 inches because this is the largest size on most 3D Printers. The LCD screen needed to be high up so whoever was using it could easily read it. The distance sensor was originally in the base, but it was moved to the upper section to make 3D printing easier and to make sure there weren't incorrect readings when someone moved in front of the machine. The lid originally had a removable candy holder but this was included in a more permanent way to prevent messes if the container detached while candy was still inside as well as to make printing faster. The rotor originally had 8 blades but was reduced to 4 to make sure candy dispensed in a more efficient way.

You may want to adjust these files to fit your specific parts or desires.

(Files were not properly uploading to Instructable due to an internal server error - will edit in the future)

Step 2: 3D Printing

Once you're satisfied with your files, its time to 3D Print each file.

Make sure that you use the proper settings for your printer to ensure smooth and even prints. You may need to include autogenerated supports to ensure holes like the USB port and LCD Screen print properly.

To verify the prints came out correctly, ensure that each component fits into its proper slot snugly and the pegs fit tightly together. If there are issues with any of these, you may need to check your settings and print them again.

Step 3: Breaking Off 3D Supports

Make sure to use a tool or pick to break apart any 3D supports you printed! These will mainly be in the USB Cable hole on the Base and the LCD screen slot on the Upper Section.

Step 4: Sand to Prepare for Paint

To ensure that paint applies properly, use a variety of sandpaper to lightly sand the outside faces of each print. Make sure not to sand too much from areas where components will fit in to ensure the snug fit. DO NOT SAND THE PEGS OR PEG HOLES.

Step 5: Paint and Decorate!

Next, use blue tape to tape off sections of your prints that connect the pieces together like the pegs and peg holes as well the holes for the rotor shaft. Also make sure to tape off the areas that will come into contact with candy, like the candy holder on the Lid or the shaft in the Upper Section.

Time to take your prints outside and set up a covering to use the spray paint. I would recommend covering the ground with a trash bag or with a variety of grocery bags. Apply a few coats of paint using the spray paint can while rotating the prints between coats to make sure that every section is totally covered.

Once the spray paint is dry, you can decorate the outside of the machine using any additional paint you'd like. This one is decorated with drawings of M&Ms as well as general candy since it mainly dispenses mini-M&Ms.

After you're done painting, remove the blue painter's tape and move on to the next section.

Step 6: First Assembly Step

Apply super glue to the pegs on the Base Section then attach the Upper Section. Add additional super glue into the holes from the top to ensure a tight fit. Rest something heavy like the roll of painters tape on top of the Upper Section to apply pressure while the glue sets. While waiting for the glue to dry, move on to the next section.

Step 7: Electrical Assembly

Next, start connecting all of the components to the Arduino Uno Board. Follow this rough schematic for a simple guide. Start by attaching the Motor Controller to the board (Pins 2-5) then use the Female to Male (F2M) connectors to attach the controller to the power and ground rail. Then connect the motor to the controller. Next, using more F2M connectors, attach the distance sensor to Power/Ground as well as Trigger to pin 13 and Echo to pin 12. Finally, attach the LCD display to Power/Ground and the two other pins to the I2C ports of the Arduino. After completion, the electrical assembly should look like the example.

Use electrical tape to secure any loose connections and secure the breadboard power rail.

Step 8: Add USB Cable

Push the USB cable out of the back hole in the Base Section by feeding the flat side through the hole. This will prepare the assembly for adding the next electrical bits.

Step 9: Install Rotor

Slide the rotor into the main cavity with the rotor peg facing left (distance holes below & board cavity above) then left into the rotor slot hole. Attach the stepper motor by sliding it in via the right hole to lock the rotor and motor in place. If the fit is proper, the stepper motor should not move once the rotor has been locked in.

Step 10: Install Components & Input Board

Slide the LCD screen into the proper cutout then drop the distance sensor into the two overhang holes.

Connect the USB cable to the Arduino Board then pull the cable from the outside hole to slide the board into the cavity.

Spend some time on cable management then add the Lid.

Step 11: Program Using Laptop

Plug the USB cable into a laptop then program the Arduino. The program is split into four main sections with two internal functions that are referenced:

1) Variable Creation - Used to create variables and instances for the LCD screen, the messages sent to the screen, variables used to find the distance under the overhang, and an instance of the stepper motor.

2) Set Up Function - Used to start serial communication, initialize the LCD, set up the pin mode for the distance sensor pins, set the speed for the stepper motor, and display the boot-up phrase

3) Main Loop

- Point 1: Writes the first message to the LCD and checks to see if a hand is under the overhang. Once there is a hand under the overhang, it moves to Point 2.

- Point 2: Writes the dispensing message to the LCD and spins the stepper one-half rotation for one serving. Once completed, displays the enjoy message then moves to point 3.

- Point 3: Checks the sensor until there is nothing under the overhang then returns to Point 1. This is to make sure the machine doesn't accidentally just keep dispensing if something is left underneath the overhang.

4) Function Section - Used to write messages to the LCD screen and to get a value for the distance under the overhang. This section is references during the Main loop but is also referenced during the initial Set Up.

Step 12: Enjoy!

Set up the Candy Bot wherever you'd like then put some candy in the top of the machine. I would recommend mini m&ms.

Enjoy! Thank you for reading.