SnackBot: The Internet Connected Candy Machine
Uses an iPhone to dispense candyBy Matt Haines
Developer Relations Evangelist, Electric Imp
Description: Snack Bot
Assembly Time: 2 to 3 hours
Skill Level: Intermediate
During the 2013 Bay Area Maker Faire, Electric Imp distributed an astonishing 40-plus pounds of M&Ms with our Internet-connected SnackBot. We used an iPhone to dispense the candy to anyone who came up and asked us a question. 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 on Instructables.
Foam tape (or other adhesive)
An iPhone or Android phone
Electric Imp Card
April Breakout Board
10KΩ (or higher) resistor
Step 1: Disassembling the SnackManThe 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 boar, and the NFET.
- Remove the clear plastic dome by pressing the button on front of the SnackMan.
- Remove the top piece of plastic to expose the gear cover and screw caps.
- Remove the gear cover, gear, screw caps, and screws.
- Push the button (the same button from #1) and pull up to remove the plastic cover.
- Once the plastic cover is removed, we have access to the electronics.
- Remove the screws attaching the circuit boards to the base.
- Unclip all the wires from the main board.
• The top cover and motor
• The rotary encoder (circular dial and board) from the front of the SnackMan
• The bottom of the SnackMan (with the power cable coming up from the base)
• The main board
• The IR board
Step 2: Hacking the SwitchThe SnackMan has a dial 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 care about serving size, since that will be controlled by a Web page).
Here's what we need to do:
- Snip the connector off the end of the cables.
- Pull the wires apart (this will make the next steps easier).
- Desolder all the wires except the third from the top (it should be black).
- Solder the red wire from the SnackMan's power source to the second from the top hole.
- Leave the red wire from the power source and the black wire we left next to one another.
Step 3: Adding the imp and the MotorThe next thing we need to do is get the motor hooked up to our April Breakout Board.
- Bend the NFET's leads so the outside pins line up with GND and Pin 9.
- Solder Pin S (source) to GND (on the imp).
- Solder Pin G (gate) to Pin 9 (on the imp).
- Solder the negative (black) lead from the motor to Pin D (drain).
- Flip your imp over and solder the 10kΩ resistor between Pin 9 and GND.
- Solder the black wire from the power source (base) of the SnackMan to the imp's GND pin.
- Solder the extra wire coming out of the rotary encoder to the imp's VIN pin.
- Solder the positive (red) lead from the motor to the imp's VIN pin.
- Solder your diode between the positive and negative leads of the SnackMan's motor.
- The banded/striped end of the diode should be soldered to the motor's positive (red) lead.
Pin S (NFET) to GND (imp) and
Pin D (NFET) to Negative (black) lead of motor.
2. Solder black wire from base of SnackMan to GND.
3. Solder the motor's positive (red) lead to VIN.
4. Solder the motor's negative (black) lead to middle pin of NFET.
Step 4: BlinkUp and Run CodeBefore we close up the newly imp-ed SnackBot, we're going to blink it up and run some test code to make sure everything is working correctly.
Get Your imp Online:
- Add batteries (or plug in the power cable).
- Turn the rotary encoder to any position other than the "off" position.
- Insert an imp into the SD card slot on the April Breakout Board.
- An LED inside the imp should start blinking.
- Follow the steps in our BlinkUp Instructables to get your imp online.
At this point, your imp should be blinking green to indicate that it's online and talking to our server.
Test the Hardware
- Log into Electric Imp's web based IDE.
- Copy and paste out test code into the Device window in the IDE.
- Hit Run.
Run the Actual Code
- Copy and paste the SnackBot Agent code into the Agent window of the IDE.
- Copy and paste the SnackBot Device code into the Device window of the IDE.
- Hit Run.
Step 5: Reassemble your SnackBotNow that everything is connected and tested, let's add the finishing touches.
Secure the SnackBot's Electronics
- If desired, remove the red piece of plastic. This will make BlinkUp easier in the future.
- Reattach the rotary encode/power switch.
- Add foam tape to the base of the SnackBot assembly to hold the April Breakout Board in place.
- Firmly press the April Breakout Board (with the imp) into the foam tape you just put down.
- Add the plastic cover that goes over the electronics.
- Add the plastic button.
- Screw the plastic cover in place.
- Cover the screws with the screw caps.
- Add the gear/candy dispenser.
- Add the gear cover.
- Snap the clear plastic dome into place.
Add candy and enjoy!
To see SnackBot in action, check out the following video.