I was strolling down the candy aisle at the supermarket and there it was:  the PEZ dispenser, conjuring up sweet (literally) childhood memories served up by my favorite cartoon characters in squarish sugary pellets.  Then, all of a sudden, an LED went off in my head.  PEZ meets Arduino. 

In this age of over-automation,  where robots do everything short of scratching nostrils, I figured that my sugar-dispensing childhood toy, The PEZ, also deserves automation.  


Basically, I am using an ultrasonic distance sensor to decide if someone is within 20 cm from the sensor which is attached next to PEZ.  If so, Arduino will turn the servo 180 degrees back pulling with it the ear of Mickey Mouse. When Mickey's head is pulled back, a PEZ pellet is pushed out of the mouse's mouth.  Yummy.

After a few seconds (5 seconds in my Arduino sketch) the servo returns back to 90 degrees,  closing Mickey's mouth and waiting for the next person in line to serve. 


  • The PEZ Robo Dispenser.  I picked a Mickey Mouse PEZ because big ears are better at holding a noose that will be tied to the rotating servo horn. 
  • Arduino Uno or clone. I used my GOduino III
  • Ultrasonic Distance Sensor HC-SR04. ($2.50 Ebay)
  • RC Servo ($2.50 Ebay)
  • Breadboard
  • Jumper wires
  • Wire fasteners or rubber bands
  • Battery (Anything over 7 volts with about 500mAh).
<p>Cool tutorial - very detailed and informative, yet relatively simple. I'll be looking to use some of the information you've provided in some future projects! Thanks</p>
<p>How do i open the ultrasonic map? i can't open it.. very nice project btw!</p>
<p>Thanx maker! Great fun :P Also, created a fritzing for the next curious maker - hope you don't mind.</p>
<p>Works great using a simple button and the Grove Shield from Seeed Studios with the following code:</p><p>#include &lt;Servo.h&gt;<br><br>#define SERVO_PIN 3<br>#define CLOSE_POS 90 // servo in CLOSE/UP position<br>#define OPEN_POS 180 // servo in OPEN/BACK position<br>int inPin = 2;<br>int input;<br><br>Servo myservo; // create servo object to control the PEZ servo<br><br>void setup()<br>{<br> Serial.begin(9600);<br> pinMode(inPin, INPUT); <br> myservo.attach(SERVO_PIN); // attaches the servo to pin<br> myservo.write(CLOSE_POS); // turn servo to CLOSE/UP position<br><br>}<br><br>void loop()<br>{<br> input = digitalRead(inPin);<br> if ( input == HIGH ) {<br> myservo.write(OPEN_POS);<br> Serial.write(&quot;PIN HIGH&quot;);<br> Serial.write(myservo.read());<br> delay(5000);<br> }<br> Serial.write(&quot;PIN LOW\n&quot;);<br> Serial.write(myservo.read());<br> myservo.write(CLOSE_POS); // tell servo to go to CLOSE/UP<br>}</p><p>My Kids love it! :)</p>
use a second servo to push the pez out.
or possibly you can turn the whole contraption &gt; 45 degrees until the pez falls by itself.
ha! <br> <br>it would be even funnier if the mouth would close you when got closer. <br> <br>person: &quot;hey look PEZ, don't mind if I do&quot; <br> <br>....person approaches.... <br> <br>Mickey: &quot;nope&quot;
Building on your idea, we can have two sensors one positioned higher than the other to guess if person is an adult or a kid. If someone is above a certain height, we could pull your trick with a message such as &quot;Kids only, please.&quot; Not an exact science but just for kicks :)
If you mod the head a little bit, could you get it to pop the PEZ out into your hand?
I considered mounting it on a motion sensing robot. The possibilities for this silly contraption are endless :)

About This Instructable




Bio: Did I unplug the solder iron?
More by techbitar:IR Remote Control Station for Android - TURN THE TV DOWN SensoDuino: Turn Your Android Phone into a Wireless Sensors Hub for Arduino Modify The HC-05 Bluetooth Module Defaults Using AT Commands 
Add instructable to: