Candy Claw Machine

by somo2003 in Circuits > Arduino

301 Views, 3 Favorites, 0 Comments

Candy Claw Machine

IMG-2743.jpg
IMG_0040 (1).jpg
IMG_0039 (1).jpg
IMG_2579.jpg
IMG_2691.jpg
IMG_2686 (1).jpg

By Emma Hopson and Sophia Montie


For this project, we created an interactive candy claw machine game. Our game prompts users to rotate the knobs in the control panel that rotate and bend the claw so they are able to retrieve candy in the base. Once the user retrieves the candy and drops it in the tray, they can press a button to stop the game. The display will then show them the amount of time it took for them to grab their treat!

Our inspiration for this game was to create a candy retrieval device using a claw similar to that used for an excavator. We wanted to make a device that would be fun for the user to place by including the times element in addition to the candy they may win. Contrary to a typical candy claw machine, our device has a single claw that bends down to pick up candy rather than move on a fixed track. We decided to go with this design because it allowed us to apply our skills using servo motors that we learned in lab into our final project. Each servo motor controls a different part of the arm allowing it to rotate, bend, and retrieve candy. Additionally, we implemented potentiometers to control the servo motors.

At the beginning of this project, we made a prototype of the claw made of cardboard to test the length each part of the arm needed to be in order to accurately collect the candy. To test the prototype, we found an Ibuprofen lid to use as the scoop and conveniently used the Ibuprofen as a proof of concept if the claw could grab candy. Once the arm prototype was completed, we began to prototype the button, display, and potentiometer components with a breadboard. Because servo motors are only able to move 180 degrees, we were able to program them alongside the potentiometers using the map() function included in the Arduino IDE program. 

After all of the components were connected to the Arduino through the breadboard prototype, we started to create a program for our game. We programmed the display to explain how the game works, “Move the knobs to rotate and bend the arm”, and then prompted the user to start the game by pressing the button. Once the green button was pressed, the potentiometers were activated which allowed the user to begin the game. It also started a timer using the millis() function, also included in the Arduino IDE library. Finally, when the user pressed the red button, the potentiometers stopped moving and the timer ended. The display then read the users time and started a new game. 

Once the code and circuit were created, we began soldering the circuit components. This allowed us to create a more permanent circuit. We also began to create the housing component. Initially, it was going to be 3d printed and in a more round shape, however it was going to take too long to print. Finally, we made a laser cut plywood housing and connected the circuit. 

As we finished our project, we reflected on components that we would want to improve on. If we were to attempt this project again, we would opt for stronger servo motors and a more durable servo casing. We found that through playtesting, the servos would shake at times and occasionally had trouble picking up candies, especially ones that were heavier. 


Demo video

Supplies

Circuit materials:

  • Arduino (Elegoo) Uno R3 Controller Board
  • Breadboard jumper wire
  • Potentiometer
  • Button
  • Protoboard
  • Servo motor
  • Arduino LCD 1602 display
  • Solder wire
  • 220 ohm resistor
  • 330 ohm resistor
  • 2k ohm resistor

Housing materials:

  • 1/4" Plywood
  • Wood glue
  • Acrylic
  • Plastic glue
  • 1.75 mm PLA
  • Super glue

Software:

  • Arduino IDE

Design Circuit

FinalProject_schem.jpg

The first step to this project was to determine the components that we would need for a functioning claw that the user could control from a control panel. We decided that we would need two buttons to start and stop the game, three servo motors to control the claw, three potentiometers to allow the user to move the claw, and a display to guide the user through the game.

In order for all of the parts to work together, we had to use almost all of the digital pins. The Arduino display required multiple digital pins to function in addition to a few PWM pins. Initially, we were controlling the contrast on the display through our code, however it resulted in using a PWM pin that needed to be used for another function. We solved this problem by using resistors in series to set the contrast. Furthermore, we connected the servo motors to the three leftover PWM pins. For the potentiometers to work, we connected them to the analog pins on the Arduino.

We followed the circuit diagram above to complete our circuit.

Create Code

Next, we wrote the code for the claw's servos and control panel. In order for this to be an interactive game for the user, we wanted the display to prompt the user to press the green button to start, turn the knobs on the potentiometers to move the claw, and press the red button to stop the game and record their time. We modified the "Hello World" code example found here to write the code used to display the text.

For the code to function, you will need to upload the code below to your Arduino. In order to do this, upload the code into a new Arduino IDE sketch. Next, connect your Arduino to your computer in the top left drop down menu that says "Select Board". Once you have connected your board, you should be able to upload the code to the Arduino. You can do this by clicking the blue arrow button in the top left corner.


Code

Build an Enclosure

enclosure.jpg
IMG_2685 (1).jpg
IMG_2690.jpg
IMG_2706.jpg

To create the enclosure, we needed something to house all of our circuit components as well as the candy for the user to grab. In our original design, the enclosure was more circular that would be 3d printed, however this method would have taken multiple days to print. We finally came to a decision for a box shaped enclosure. Once we designed the box and laid out all of the pieces, we converted them to DXF files and laser cut them out of 1/4 inch plywood. Next, we glued the pieces together with wood glue.

In order to create the housing, you may download the .dxf files below. These files can be laser cut onto many materials such as cardboard or plywood, but we found plywood to work for us. We used wood glue to join all of the housing pieces together.

The housing for the servos was made from acrylic that was also designed and laser cut from .dxf files.

Downloads

Join Circuit With Enclosure

IMG-2747.jpg
IMG-2741.jpg

To join the circuit with the enclosure, we began by feeding the buttons and potentiometers through the control panel. We then incorporated the servo claw, followed by the display. We attached these components with super glue. Additionally, we used a Dremel to make a hole for the USB to connect the computer.

Playtest

IMG-2745.jpg

Once everything was joined together, we gave it a few play tests. We found that the M&Ms were easier to grab than the starbursts, but we were able to grab a few of each. In addition, we found that the best method of retrieval was to raise the arm as we scooped the candy. This ensured that the candy would stay inside the scoop.

Included below is the final demo video that shows how the candy machine works.