Picture of PEZ Robo Dispenser Using Arduino
pez-robo (5).JPG
pez-robo (9).JPG
pez-robo (13).JPG

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. 

Remove these adsRemove these ads by Signing Up


Picture of PARTS LIST
  • 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).

Step 2: Wiring Robo PEZ

Picture of Wiring Robo PEZ
  • Black ---> Arduino GND pin
  • Red ---> Arduino 5V pin
  • White/Yellow ---> Arduino 9 pin

  • GND pin ---> Arduino GND pin
  • VCC pin ---> Arduino 5V pin
  • TRIG pin ---> Arduino 12 pin
  • ECHO pin ---> Arduino 13 pin

Jelmer82 months ago

How do i open the ultrasonic map? i can't open it.. very nice project btw!

Kelly Smith made it!1 year ago

Thanx maker! Great fun :P Also, created a fritzing for the next curious maker - hope you don't mind.

RoboPez fritz screeny.png2014-02-23 08.21.47.jpg
mmacdonald-wallace made it!1 year ago

Works great using a simple button and the Grove Shield from Seeed Studios with the following code:

#include <Servo.h>

#define SERVO_PIN 3
#define CLOSE_POS 90 // servo in CLOSE/UP position
#define OPEN_POS 180 // servo in OPEN/BACK position
int inPin = 2;
int input;

Servo myservo; // create servo object to control the PEZ servo

void setup()
pinMode(inPin, INPUT);
myservo.attach(SERVO_PIN); // attaches the servo to pin
myservo.write(CLOSE_POS); // turn servo to CLOSE/UP position


void loop()
input = digitalRead(inPin);
if ( input == HIGH ) {
Serial.write("PIN HIGH");
Serial.write("PIN LOW\n");
myservo.write(CLOSE_POS); // tell servo to go to CLOSE/UP

My Kids love it! :)

use a second servo to push the pez out.
techbitar (author)  astral_mage1 year ago
or possibly you can turn the whole contraption > 45 degrees until the pez falls by itself.
whiskey_141 year ago

it would be even funnier if the mouth would close you when got closer.

person: "hey look PEZ, don't mind if I do"

....person approaches....

Mickey: "nope"
techbitar (author)  whiskey_141 year ago
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 "Kids only, please." Not an exact science but just for kicks :)
pansartax2 years ago
If you mod the head a little bit, could you get it to pop the PEZ out into your hand?
techbitar (author)  pansartax2 years ago
I considered mounting it on a motion sensing robot. The possibilities for this silly contraption are endless :)