Smiley - a Smile-triggered Candy Machine That Shares!




Introduction: Smiley - a Smile-triggered Candy Machine That Shares!

Below is the process I went through to create Smiley, the smile-triggered candy machine that invites and shares the reward simultaneously!

Step 1: Smiley Video

Step 2: Tools and Materials

  • Arduino Uno kit
  • Experimenter’s Guide for Arduino
  • Candy Wizard: Motion Activated Candy Dispenser (Here's the one I got!)
  • Small phillips screwdriver
  • Soldering iron and solder
  • Stranded wire
  • Wire strippers
  • Wire snips
  • Webcam
  • Laser Cutter
  • 1/8” acrylic
  • Acrylic Solvent
  • Candy
  • Your Face!

Step 3: Recognizing Smiles and Coding Arduino

  1. Download and Install the Auto-Smiley App
  2. Once you have downloaded and installed the AutoSmiley app, open it and make sure it connects to your computer’s webcam and recognizes your smile. It should look like the two photos seen above.
  3. Download from
    1. Open ‘other’ folder
    2. Open OF_serialTest folder
    3. Open OF_serialTest.pde
    4. and copy the following code into Arduino:

      int ledPin = 13; // select the pin for the LED 
      int val = 0;       // variable to store the data from the serial port
      void setup() {
        pinMode(ledPin,OUTPUT);   // declare the LED's pin as output
        Serial.begin(9600);        // connect to the serial port
      void loop () {
        // read the serial port
        val =;
        // if the input is '-1' then there is no data
        // at the input, otherwise check out if it is 'a'
        // if it is, send back a message "ABC"
        // and turn on and off the LED on pin 13
        // note, it takes about 5-10 seconds for the tx/rx of arduino to get
        // settled.  wait briefly after uploading, then open the serial monitor
        // when you type in a (and press send or return) you should see ABC returned
        // in the console below. check this first, and then try the openframeworks example
        // in OF, you need to specify clearly which serial port you are communicating on. 
        // take a look above at "tools > serial port"
        // ie, "COM7" or "dev/tty...."
        // and make sure that is put into your code when you use ofSerial
        if (val != -1) {
          if (val == 'a') {
            Serial.print("ABC");        // send back a message simple as ABC
            digitalWrite(ledPin, HIGH);
            digitalWrite(ledPin, LOW);

      4. Once in Arduino, change the underlined and bolded text to the following: if (val == ‘:') {

      5. Build push button with LED example.

      6. Verify your code and upload it to your Arduino board.

      7. Next, open the serial monitor by clicking the top left button with the magnifying lens.

      8. Once you have the serial monitor open, type a colon (:) into the top ribbon. If your code is correct the serial monitor should respond with ‘ABC’ and momentarily illuminate your LED.

      9. Once this code works, build the Spin Motor Spin circuit (CIRC-03) which can be found in the Experimenter’s Guide for Arduino.

      10. Once the motor circuit is built, download the attached Smiley.ino code (which combines the LED code with the motor controls)

      11. Verify your code and upload it to your Arduino board.

      12. Next open your serial monitor and type a colon (:) into the top ribbon. If your code is correct, when you send the colon, your serial monitor should respond again with ‘ABC’ as well as run your motor for 5 seconds.

      13. Next open up the Auto Smiley app. Click into the text ribbon in the serial monitor and SMILE.

      14. The Auto Smiley app should send the :) signal to your serial monitor. The serial monitor will recognize the colon (:) and will respond with ‘ABC’ as well as trigger your motor to run for 5 seconds! *(The Auto Smiley app will type :) into any application you have open that allows typing, so be careful not to accidentally smile while clicked into your code window)*

Step 4: Circuit Diagram

Step 5: Candy Wizard Teardown, Soldering, and Physical Testing

  1. Using a small phillips screwdriver, take apart the candy wizard into individual pieces.
  2. Disconnect the IR sensor, circuit boards, wires, and remove the motor from its housing.
  3. Disconnect the existing wires from the motor and solder longer wires in their place.
  4. Re-install motor and and candy wizard top half, excluding the circular base with column.
  5. Run two motor wires through access hole in the bottom of the square base.
  6. Once the candy machine is put back together, connect your two motor wires back to the arduino circuit.
  7. Pour in candy, open arduino with final code, open the serial monitor, open up the Auto Smiley app, click into the top ribbon of the serial monitor………..
  8. And SMILE!!!!

Step 6: Building the Smiley

  1. Download the attached Ai templates to use as laser cutter files.
  2. Using acrylic solvent, attach the bottom and three sides of the box.
  3. Next build a ramp. Mine was a pretty rushed assortment of materials in order to split the feed of candy in half and deilver to both sides of the Smiley box.
  4. For the little trays on either side, use acrylic solvent to attach 4 layers of semicircles to the base.
  5. Once trays and inner ramp are installed, place your arduino board in the box and run your arduino and webcam cables through the hole on one side of the box.
  6. Test how the candy rolls down the ramp, and attach 4th side of the box.
  7. Check placement of webcam and use solvent to adhere to the lid before covering it with the triangular housing.
  8. Attach two narrow pieces to the underside of the lid, placed exactly an 1/8” from the adjacent 3 edges. This will make it easy to stablilize the lid without having to attach it permanently.
  9. Pour candy, plug in, and smile!

Be the First to Share


    • CNC and 3D Printing Contest

      CNC and 3D Printing Contest
    • Puzzles Challenge

      Puzzles Challenge
    • Rice & Grains Challenge

      Rice & Grains Challenge



    7 years ago

    You could legitimately sell this to every dentist office


    7 years ago on Introduction

    Wow, this is such a cool idea. Very well executed too!