Introduction: SnackBot: the Internet Connected Candy Machine!

During the 2013 Bay Area Maker Faire, Electric Imp distributed an astonishing 40-plus pounds of M&Ms with our Internet connected SnackBot. Hundreds of attendees loved it, so we decided to share how we built it.

Our SnackBot is based around the Electric Imp, a hardware, software and cloud-based platform that makes it easy to connect just about anything to the Internet. If you are new to Electric Imp, you can check out our Instructables on Getting Started With the Electric Imp, which will guide you through the process of getting your imp online and running some basic code.

This project involves a bit of soldering (and desoldering), and should take you about 2-3 hours to complete!

Let's get started!

Step 1: Parts & Supplies

To complete this project, you are going to need the following:
You are also going to need some tools:
  • Philips Screwdriver
  • Soldering Iron
  • Solder
  • Foam Tape (or other adhesive)
  • An iPhone or Android Phone

Step 2: Disassembly

The first thing we need to do is disassemble the SnackMan. We're going to take out (almost) all of the electronics, and replace them with an April board, and the FET.

Disassemble the SnackMan:
  1. Remove the clear plastic dome by pressing the button on front of the SnackMan.
  2. Remove the top piece of plastic to expose gear cover and screw caps.
  3. Remove the gear cover, gear, screw caps, and screws.
  4. Push in on the button (the same button from #1) and pull up to remove the plastic cover.
  5. Once the plastic cover is removed, we have access to the electronics. 
  6. Remove the screws attaching the circuit boards to the base.
  7. Unclip all the wires from the main board.

You should now have 5 pieces:
  1. The top cover + motor
  2. The rotary encoder (circular dial + board) from the front of the SnackMan
  3. The bottom of the SnackMan (with the power cable coming up from the base)
  4. The main board
  5. The IR board

You won't need to use the main board (4) or IR board (5), so they can be discarded (or kept for future projects if you like).

Step 3: Hacking the Switch

The SnackMan has a dial that's used to turn the machine On and Off, as well as control the serving size. We're going to modify it to act as a power switch for the imp.

When the switch is in the Off state, the SnackBot will be off. In any other state, the SnackBot will be on. We don't need to worry about controlling the serving size, since that will be managed by our webpage.

Here's what we need to do:
  1. Snip the connector off the end of the cables.
  2. Pull the wires apart (this will make the next steps easier).
  3. Desolder all the wires except the 3rd from the top (it should be black).
  4. Solder the Red wire from the SnackMan's power source to the second from the top hole.
  5. The red wire from the power source, and the black wire we left should be next to one another.

Step 4: Adding the Imp and the Motor

The next thing we need to do is get the motor hooked up to our April board:
  1. Bend the NFET's leads for the outside pins line up with GND and Pin9 (see image).
  2. Solder Pin S (source) to GND (on the imp).
  3. Solder Pin G (gate) to Pin9 (on the imp).
  4. Solder the negative (black) lead from the motor to Pin D (drain).
Flip your imp over:
  1. Solder the 10kΩ resistor between Pin9 and GND.
Hooking the imp up to power:
  1. Solder the black wire from the power source (base) of the SnackMan to the imp's GND pin.
  2. Solder the extra wire coming out of the rotary encode to the imp's VIN pin.
  3. Solder the positive (red) lead from the motor to the imp's VIN pin.
Add the diode:
  1. Solder your diode between the positive and negative leads of the SnackMan's motor (see image).
    • The banded/striped end of the diode should be soldered to the motor's positive (red) lead.

Step 5: BlinkUp and Run Code

Before we close up the newly imp-enabled SnackBot, we're going to blink it up and run some test code to make sure everything is working correctly.

Get your imp online:
  1. Add batteries (or plug in the power cable).
  2. Turn the rotary encoder to any position other than the "Off" position.
  3. Insert an imp into the SD card slot on the April board.
  4. An LED inside the imp should start blinking.
  5. Follow the steps in our BlinkUp Instructables to get your imp online.
  • If your imp didn't turn on, you likely have wiring issue. Go back and double check you soldered all things that needed to be soldered.
At this point, your imp should be blinking green, to indicate that it's online and talking to our server. 

Test the hardware:
  1. Log into Electric Imp's web based IDE.
  2. Copy and paste the test code from our SnackBot repository into the Device window in the IDE.
  3. Hit Run.
  • The motor should have turned on for 10 seconds, then turned off again. If it didn't, you have a problem and you should make sure the NFET is facing the correct direction.
Run the Actual Code:
  1. Copy and paste the SnackBot Agent code into the Agent window of the IDE.
  2. Copy and paste the SnackBot Device code into the Device window of the IDE.
  3. Hit Run.
When you browse the device's Agent URL, you should be presented with a webpage. If you click one of the buttons, it should turn on the motor and dispense candy.

Step 6: Reassemble Your SnackBot

Now that everything is connected and tested, let's add the finishing touches.

Secure the SnackBot's Electronics:
  1. If desired, remove the red piece of plastic. This will make BlinkUp easier in the future.
  2. Reattach the rotary encode / power switch.
  3. Add foam tape to the base of the SnackBot assembly to hold the April breakout board in place.
  4. Firmly press the April breakout board (with the imp) into the foam tape you just put down.
Reassemble the rest of the SnackBot:
  1. Add the plastic cover that goes over the electronics.
  2. Add the plastic button.
  3. Screw the plastic cover in place.
  4. Cover the screws with the screw caps.
  5. Add the gear / candy dispenser.
  6. Add the gear cover.
  7. Snap the clear plastic dome into place.
  • Refer to Step 2 of the Instructables for reassembly.

Add Candy and Enjoy! 

Comments

author
MauriceF3 made it! (author)2017-02-15

These instructions emboldened me to try modding my candy machine. And without it I might not have guessed that those dimples were screw covers. To make it even simpler for myself, after disconnecting the built in logic board and sensor, I connected the internal power directly to the motor, without adding my own logic board. Now it puts out treats continuously as long as it has power, and I use my wifi smart plug to control it, so I can dispense treats to my cat and dog from my phone. I also mounted it to a board with re-stickable picture hanging tape to protect the power cord and keep the pets from knocking it over.

20170215_222504-1.jpg
author
bigdana made it! (author)2016-10-07

This has been so much fun to make and play with! Thanks for the instructions! :)

Screen Shot 2016-10-07 at 11.25.58 AM.pngScreen Shot 2016-10-07 at 11.26.52 AM.png
author
HagenD made it! (author)2015-10-18

So great! Worked first time. Thank you for this contribution.

author
sogseal made it! (author)2015-02-17

great indestructible! This got me thinking, im trying to make a imp electronic door lock and my issue is to make the DC motor stop after i started it, so with the values you set on the Agent side 0.4,0.8, will test that this weekends. Im glad i ran into this! Thanks man

author
mohsennoruzi made it! (author)2013-10-20

Hi beardedinventor, your project is nice and wonderful, i want to create it, can i have pdf and program this project. please send article to my email:mohsennoruzi@gmail.com. thankyou

author
linobellone made it! (author)2013-10-04

I try it , seems very simple, but mine doesn't want to go !!! Do you use 4 AA batteries?
Thanks for any suggestion.

author
cat-haines made it! (author)cat-haines2013-10-07

I've used 4xAA batteries, as well as the power cord, and both should work.

Does your imp turn on when it's plugged into the SD socket (it should 'click' in) and you turn the power knob? It should start blinking orange if it's a brand new imp.

author
linobellone made it! (author)linobellone2013-10-16

Dear beardedinventor,
now is ok!! The Nfet was wrong : was a IRF510PBF and not a IRLB8721PBF, so I changed to the last one and now is worked very fine.
Thank you

author
gregoryfenton made it! (author)2013-09-22

I did something very similar to this last year using twitter and searching for the hashtag #candy4greg. A great way of being fed candy at random times, the only issue was getting to the dispenser before the kids did :P
http://labby.co.uk/?s=candy4greg

author
DesignsWright made it! (author)2013-09-10

Great Instructable. Now to rework it with something other than the IMP... :-)

author
wylekat made it! (author)2013-09-10

Just as a suggestion... Put in a 'random' button.

author
mjhungvit made it! (author)2013-09-06

So good

author
emilyvanleemput made it! (author)2013-09-06

Awesome!

About This Instructable

30,139views

309favorites

Bio: Lead Developer Advocate at Pebble (previously ran community at Electric Imp). I love coffee, robots, and building hardware that lives on the web!
More by cat-haines:ISS OverheadImpower - The (Electric Imp powered) Internet Connected AC OutletElectric Imp
Add instructable to: