Stupid Pet Trick (Marcela)

Date: March, 13th 2017

Instructor: Marcela Godoy

Candy Dispenser

Carlo Gabriel

About Candy Dispenser:

For stupid pet trick project, we were assigned to create an interactive machine out of Arduino. This time, we had to apply all the knowledge that we have got so far in class. I came up with an idea of using servo as my major component. Then, I finally decided to make a simple candy dispenser. This machine is really simple, however from this simple DIY candy dispenser, you can entertain other people, not only with the candies, but also with one fact that this machine sometimes does not give people any candy which I think it’s really stupid.


  1. Arduino
  2. Servo
  3. Cables
  4. Breadboard
  5. switch
  6. Cans (2)
  7. Glue gun

Build the Circuit

  1. Make sure that the two cans the we use in this project has different size; one is small and the other is big. First, you gotta make a small hole on the two can for the joint and servo place.
    IMG_2075 IMG_2076
  2. After you make a hole on both can, now install the servo on the big can. Use glue gun to make the servo position fix by sticking it to the can. After you stick the servo to the big can, now you need to attach the servo propeller to the small can. Now you can combine the two cans.
  3. After you’re done with the machine, now you have to upload the code to your arduino so that your candy dispenser work according to your desire.
  4.  IMG_2112 IMG_2113 IMG_2114


Arduino circuit  and code

  1. Follow the instruction below for the circuit
    Screen Shot 2017-03-14 at 12.36.51 AM
  2. Arduino Code

#include <Servo.h>

Servo myservo;

const int servoPin = 9;
const int buttonPin = 12;
const int ledPin = 13;

void setup() {
pinMode(buttonPin, INPUT);
digitalWrite(buttonPin, HIGH);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);

void loop() {
int buttonVal = digitalRead(buttonPin);
if(buttonVal == LOW) {

Now that you’re set with all the machine and the circuit. Then upload the code you to your Arduino! Don’t forget to share as much candy to your friend as possible.

Check out the video for more fun:



Working on this project was super fun! I had a few problems with the machine but I finally figured it out.


2 thoughts on “Stupid Pet Trick (Marcela)

Leave a Reply