Secret Knock Gumball Machine (Revised)

by Guinn05 in Workshop > Tools

450 Views, 1 Favorites, 0 Comments

Secret Knock Gumball Machine (Revised)

IMG_6570.jpg

What is it?

Based on the Makezine secret knock gumball machine, we’ve designed a version of the gumball machine made with 3D printed and laser cut parts rather than parts cut out with a saw, as well as an adjusted code to make it run more consistently. 


Create your own gumball machine that only allows you to access a prize when you know a secret knock. The gumball machine allows you easy access to the clear dome to allow you to change what kind of prizes you and your friends get to access. The machine also allows you to customize your knock in a highly intuitive way to ensure only you ever know the secret code. 



How can I use it? 

Once your project is finally done, to use your gumball machine, all you have to do is knock in the correct tempo over the space you chose to house your knock sensor. In our example, it's under the red fire logo on the left wall of the body of the machine, but it can really go on any flat surface you choose. 


Refilling the gumball machine is a low-tech process. All you do is lift the clear dome from the 3d-printed seal and carefully gather any loose prizes that may be lying on the servo and its components. To replace or refill prizes, fill the clear dome no more than ¼ of the way full. This is to prevent the servo from getting stuck. When you have your new prizes in the clear dome, quickly turn them over onto the servo and its components by fitting the dome to the hole. Use the 3d-printed seal to ensure the clear dome does not wiggle too much during the machine’s use.





Supplies

Materials:

Equipment:

Files: 


Resources: 

https://makezine.com/projects/secret-knock-gumball-machine/


Getting the Parts Together

Before we can get started with anything, we should make all the parts we need for the case and dispenser wheel! I personally recommend using a 3D printer for the parts I listed and a laser cutter for the wooden parts, but cutting the parts out you need with a saw or finding other ways to construct the wheel work too!


- 3D Printing

Below, you will find a link to a zip file you can download that will have all the parts 3D printed for this project. You only need to print one of each (though, if it’s easier and/or cheaper, feel free to make the base out of plywood instead of printing it). We printed ours on an Ultimaker 3 Extended printer, which isn’t necessarily the smoothest printer around, but it did the trick! We also just regular PLA filament to print. 

https://drive.google.com/file/d/13X1qCBfL9iMYC6ypjAo6T7Jj_1gEuQHe/view?usp=sharing


- Laser Cutting

Below is a link to a pdf with all of the measurements for the wooden parts you need to cut out (either by laser cutting or with a saw of some kind). You’ll need to cut out everything except the dispensing wheel and stir plates, as well as anything needed for the gumball tray, since these will be 3D printed.

https://cdn.makezine.com/make/25/secret_knock_gumball_plans.pdf


- Other

There are four wooden pillars that are needed for building this, which will need thicker pieces of wood to be cut out into 17 cm tall, 2.5cm x 2.5 cm blocks. You will also need two that are 3.5 cm talls, and two that are 6.5 cm tall.



Building the Case

IMG_6476 (1).jpg

You will want to start by attaching the four 17 cm tall wooden blocks to the side panels using wood glue and/or wooden screws. You will be putting two on each side, at the edges of the larger part of the panel. Then, you will want to attach the 3.5 cm tall pillars at the short ends of the side panels.


Then, you will attach these two sides to the bottom panel using wood screws that go through the bottom into each of the six pillars. Then, you can attach the back panel by screwing it into the very back pillars, and the smaller front panel by screwing it into the front pillars. You won’t want to attach the top, exit, or LED panels just yet though. However, on the LED panel, you will want to screw two holes into the top and screw in the two LED holders.



Building the Funnel

funnel 1.jpg
Funnel 2.jpg
FUnnel 3.jpg

Now, you’ll want to take the two funnel ends and use wood glue or screws to attach the slanted pillar pieces to the front. Then, you will want to use wood glue to attach the funnel sides to the edges of these front pillars. Finally, you will screw the funnel to the bottom of the lid, so that the hole in the top lines up with the funnel.

Building the Wheel

IMG_6595.jpg
IMG_6594.jpg

To build the wheel, you will need to start by grabbing your long bolt, two nuts, the wheel, and both wheel sides. You will want to hold the wheel and bothe wheel holders together so that the holes of all three line up and the wheel holders and both at the same level. Then, you will put the bolt through all three (starting from the side with the raised circular bit), before securing all three together with the first nut. Then, you will take the wheel panel with the smaller, circular hole, and push the bolt through that as well so that the inside nut is flush with the wood, then tighten it all together with the second nut on the other side. If the wheel has trouble turning, you can loosen the outside nut.


Next, you will glue and screw down the servo horn to the raised circular part of the outside wheel holder, then take the other panel with the larger square hole and screw the servo into place so that it will fit into the glued down servo horn. 


Before attaching the servo panel to the wheel, you will want to drill holes into the bottom corners of both wooden panels, then screw in the 6.5 cm long wooden pillars onto the wheel panel. Then, acrefull attach the servo panel by pushing it into place in the servo horn and screwing that side to the two wooden pillars as well. 


To secure the wheel into place, you will want to use wood glue to attach it to the base panel, line the whole thing up with the top panel, and then put two screws through the very bottom panel through the base to hold it in place.



Wiring the Electronics

secretknockschematic.PNG
Secret Knock Gumball Machine Breadboard Diagram.png
10kohm.PNG
150ohm.PNG
Mohm.PNG

The original Makers instruction guide presented a wiring diagram for a perf board. Since breadboards are more commonly used and require less experience to assemble, we have incorporated a schematic diagram of a breadboard circuit along with a more comprehensive general circuit diagram.

The electronics above show the use of both male and female wires. Use as needed per the diagram. There are some important reminders.


Remember to input the LEDs at the correct orientation (positive and negative). As a reminder, all general LEDs have a slight flat edge and a round edge. Make sure the negative flow connects to the flat side whereas the positive connects to the round.

The potentiometer is important to set the strength of the knock required to set off the Piezo sensor. Rotate counterclockwise to increase the resistance, requiring a more powerful knock. Rotate clockwise to decrease the resistance value. Be careful: having the resistance value too low will set off the piezo at any slight movement, making the machine impossible to use. For this reason, err on the side of a higher resistance. 


The resistors we are using are as follows:


Finally, while copying the circuit layout, always beware of any short circuits that may occur from crossing wires. Be sure to also check each output and be sure it is responsive.

The above schematic may be helpful to more simply understand what connections are being made in the circuit. The hardest part to understand is the wire connection from A1 to the 10K ohm resistor. This is actually the potentiometer transmitting the output to A1. The symbol with three descending lines of smaller lengths signifies the ground. The Switch is indicated by the horizontal line with a small vertical line off center toward the 5v. This part of the circuit will allow you to program your secret knock.

Uploading the Code

Copy and paste the code from https://cdn.makezine.com/make/25/secret_knock_gumball_machine.pde into the Arduino IDE. We use Arduino 1.8.19, but you may also use the more recent versions. Download IDE software here


After pasting the code, upload the code to your Arduino Uno or other board that you might be using. 


We did however uncomment the debug code so that we could troubleshoot the wiring.



Attaching the Electronics

IMG_6475.jpg
IMG_6532.jpg
IMG_6655.jpg
IMG_6668.jpg

Once you finish setting up all the electronics, you will want to plug the servo in and tape the knock sensor into the inside of the left side panel, where you will be able to do your secret knock. Then, you will put your RedBoard/Arduino and Breadboard into the case under the LED plate, push the potentiometer through one of the holes in the back, and the push button through the other, where you can glue or tape them to keep them in place. I would recommend using zip ties now to secure/organize all your wires so that they’re easier to keep inside the case when we attach the rest of the panels.

Attaching the Last Three Panels

Finally, you can attach the last three panels. Start by placing the LED panel on top of the electronics and putting the LEDs into the LED holders, then you can screw the front side of this panel into the front two pillars. Next, you can attach the top by screwing all four corners into the four tall pillars, making sure that the funnel lines up with the wheel. Finally, you can attach the exit panel to the front with two screws going through the middle of the two front tall pillars, so that they don’t collide with the screws holding the top in place.


Now, you can use wood glue to attach the gumball tray to the LED panel, sliding it in through the exit panel so that the sides of the tray are flush with the exit panel. Then, you can put gumballs in your gumball holder, and put it on top of the case!

Troubleshooting

After finishing with the wiring for the first time, there were a few issues.


First, the piezo buzzer wasn’t consistently responding to our knocks and constantly dropped inputs.


Second, the servo used on the dispensing wheel wasn’t strong enough to rotate far enough to dispense a gumball (or in our case, a plastic sphere).


Third, though it’s a smaller problem, all of the wiring didn’t fit within the case. This means that we need to troubleshoot.


It’s worth noting that if you’re making your own gumball machine, you might encounter different issues than we did.


Fixing the Inputs:


The first issue we needed to fix was the inconsistent inputs, as they’re the most important for using and testing the gumball machine.


We started by inserting lines of code that printed out the values of the input from the piezo and the threshold needed for an input to be registered. These values were printed in a fast loop so they were constantly updated.


We did this so we can use the potentiometer that we wired to adjust this threshold. 


The original value that we had was too high to consistently get an input, so we adjusted the potentiometer to lower the threshold. This gave us a threshold value that was too low and had the machine receiving constant inputs from nothing. We repeated this process of adjusting the potentiometer higher and lower until we had a good value that was able to read intentional inputs, but not activate at the slightest touch.


Fixing the Servo Strength:


Next on the list is the weaker servo, and this was one of the issues that we had no idea what was causing it, so we looked at all the different components.


First, we decided to start looking for issues in the code that related to the rotation of the servo so that we can find if the code gave weaker rotations to the servo. This wasn’t the case however as the code had 140 degree rotations for dispensing the gumball. We tried changing this number to 180 degrees to see if it made the servo rotate far enough, but it didn’t change anything when we tested the servo inside the case.


After being given unchanged results, we took the dispensing wheel with the servo out of the case to test the electronics. Interestingly, without changing anything, when we tested the servo, it rotated just fine.


This is because the issue wasn’t because of the electronics or the code, but because of the placement of the dispensing wheel inside the case.


The wheel was placed too close to the side of the case so that it couldn’t freely rotate.


All we had to do was manually move the wheel a small distance away from the side, and it could manually move again.