Introduction: Arduino Controled Dog Food/treat Dispenser

Picture of Arduino Controled Dog Food/treat Dispenser

In this Instructables I will be describing how to build an automatic dog treat/food dispenser using an Arduino Duemilanove (the Uno is the newest version of the same board). The timer interval can be adjusted via a potentiometer and can be set to any min or maximum value in the code. This project does not require extensive coding knowledge knowledge and leaves a lot of space to be modified. It is also designed to use as few parts as possible while trying to keep costs down and dogs happy :)



Step 1: Parts Needed

Step one is to gather the parts needed.

Parts:

1 or more dogs (these are imperative for quality control and testing purposes! Cats can be used as a substitute in a pinch but results cannot be guaranteed)

Electronics:
1 Arduino board (any arduno board will work i used an older Duemilanove )
1 Standard servo
1 potentiometer (any valued potentiometer will work, i used a 50kohm)
1 9v battery and holder

*Optional*
1 switch
1 LED (not required but fun for blinking)

Hardware:
1 1/4 (6mm) x 3.5" x 36" Plywood
2 sheets of acrylic 11" x 14" (you can use any thickness or even substitute it with plywood however you wont be able to see into the case)
wire
hinges
screws

Tools:
Wire cutter/Strippers
Saw
Soldering Iron
Drill
Glue gun

*NOTES* - templates are provided as a reference when cutting the various parts however always double check as they may not be 100% accurate.

Step 2: Build the Base Box

Picture of Build the Base Box

Cut the parts for the outside box out of the 1/4 (6mm) x 3.5" x 36" Plywood sheet. Glue the bottom and the two sides together but don't add the top piece yet.

*Notes* - Acrylic can be used here for a fully clear box

Step 3: Build the Servo Holder

Picture of Build the Servo Holder

Cut the parts for the servo holder and glue them together using hot glue, super glue and acrylic don't mix :( it causes the acrylic to go white)

Cut the parts for the back and front acrylic sheets.

Mount the servo holder to the back plate (horizontally centered ), and approximately 1 inch from the bottom

Glue the back piece to the outside box

*Notes* - don't use super glue!! i made this mistake :( it was the first time i have used acrylic in a project

Step 4: Cut Out the Servo Wheel

Picture of Cut Out the Servo Wheel

Cut the circles out of acrylic. Use a cd to trace out the size of the circle. I used a pare of wire cutters and very carefully cut out a rough circle which i then sanded to a smoother circle as shown in the pictures.

*Notes* -  This takes a little while to get right, i recommend practicing on some scrap pieces or use a band saw if you have one (on my wish list :) )

Step 5: Build the Wheel

Picture of Build the Wheel

Attach the servo arm to one of the circles making sure it is centered.

While that is drying cut out the rest of the pieces for the in the wheel. Fit one piece into the other to create an X and glue this to the wheel (see pictures).

Once the wheel is built use a 2L coke bottle to cover 3 of the 4 quadrants of the wheel as represented by the red in the picture. This leave one segment open for the food to fill

*Notes* - I didn't screw the servo arm back into the servo which allows me to remove the wheel, so far it hasn't fallen off yet (touch plywood:), this also helps when it has to be cleaned

Step 6: Mount Arduino Board and Connect Servo

Picture of Mount Arduino Board and Connect Servo

Drill holes (carefully) to mount the Arduino board.

Attach the 9V battery holder to the side wall with a little hot glue and connect it to the arduino via an old ac adapter end piece

You can either create a servo harness out of some old rc parts laying around (see picture) or cut the connector off the end of the servo wire

Attach the black wire from the servo to GND on the Arduino, the red wire to VCC or 5V, and the white wire to pin 3 on the arduino

Optional: attach the led to pins 10 and 11 (the long pin or anode to pin 11 and the short pin or cathode to pin 10)
(see picture)

*NOTES* - You can install a switch by splicing the 9V battery wire and mount it to a hole in the side (see pics for the addition)

Step 7: Install Top Ramp

Picture of Install Top Ramp

Mount the wheel to the servo

Cut out the parts for the top (feed) ramp.

With the wheel mounted on the servo carefully position the pieces for the top ramp (the two square ones) and glue them (see pictures)

Once these have dried glue the third piece

*NOTES* - you may have to sand down some pieces to create a snug fit

Step 8: Install Exit Ramp

Picture of Install Exit Ramp

Attach the 9V battery clip/holder as shown
(i used a 9v clip and attached it to an old ac adapter end)

Install the exit guard that guides treats to the hole, also install the exit ramp which help prevent treats getting stuck on the ledge as shown in the pics

*Notes* - Make sure to fit everything before you glue it, also test it with the wheel on to make sure it doesn't get stuck

Step 9:

Picture of

Mount the potentiometer to the front acrylic piece. (i used some hot glue)

Attach the leads from the potentiometer to the Arduino. The first pin should go to pin 4, the middle pin should go to A0 (analog 0 ) and the third pin should go to ground (GND)

You can attach the front piece to the unit using either tape or glue. I'd recommend using tape or adding a set of hinges to give easy access to the Arduino board for reprogramming of testing. However be careful as the acrylic can crack very easily when drilling it

*NOTES* - you may not want to glue on the front piece as this may make getting into the box to modify the code difficult

Step 10: The Code

Picture of The Code

Connect the Arduino to your computer  via USB ( if you don't know how or are not sure as to how to do this see http://arduino.cc/en/Guide/HomePage )

Download and open the Arduino IDE from http://arduino.cc/en/Main/Software

Copy and paste the code below:


//BEGINNING OF CODE
//Author: Shane Halse
//Email: ShaneHalse@gmail.com
//Date: 02/11/2011
#define fill 155 //the position in degrees to fill the hopper
#define empty 20 //the position in degrees to empty the hopper
#define potPin A0 //this is the pin (must be analog) that the middle of the potentiometer is connected to

#include <Servo.h> //this is a library used to control a servo (for more information see www.arduino.cc for more info)

//variables
Servo mainServo; //declare the main servo
int trigger = 0; //this is used to switch between fill and empty
int potIn = 0; //this is the data read from pin A0 (the potPin)
int count = 1; //used as a time muliplier
void setup()
{
//basic setup
mainServo.attach(3); //tell arduino which pin the servo is on (the white wire from the servo)
//set the pin modes
pinMode(4, OUTPUT); //used to output 5V or High to the potentiometer
pinMode(10, OUTPUT); //used for the led
pinMode(11, OUTPUT); //used for the led

digitalWrite(4, HIGH); //set pin 4 high
digitalWrite(10, LOW); //set pin 10 low
}


void loop()
{

potIn = analogRead(potPin); //read the position the potentiometer is at
//if the trigger value is 0 fill the hopper
if(!trigger)
{
mainServo.write(fill);//move servo to fill position
//this is used to setup the delay
//count = 171 //uncomment this to set the max delay to 3 hours
//the delay below is calculated using potin (which can be 0-1024) as delayinseconds ~= 0 - 64 seconds
for(;count>=0;count--)
{
for(;potIn>0;potIn=potIn-20)
{
//this is to make the LED flash every 100+potIn miliseconds
digitalWrite(11,HIGH); //set led to on
delay(100+potIn);
digitalWrite(11,LOW); //set led to off
delay(100+potIn);
}
}
count = 1;
trigger = 1; //change trigger to 1 to setup empty
digitalWrite(11,LOW); //set led off
}
else if(trigger)
{
mainServo.write(empty); //set the servo to empty position
delay(1000); //delay while servo sets position
trigger = 0; //change trigger to 0 to setup fill
}
}
//END OF CODE


Connect the Arduino to your computer 
click the compile button
Upload the compiled code to the board and it should start working automatically

You can then mount the unit to the wall, place a bowl under the unit and let the fun ensue!

*NOTES* - If you want you can add some sort of button your dog presses to get a treat rather than waiting and you will have just made the famous Skinner box!

Comments

Topgambling26 (author)2017-03-03

Would it be possible to set this up with a motion sensor?
I'd like a cat feeder were the cat would have to activate motion sensor to release a few bits of kibble each time to slow down there eating.
Is this possible I have never seen anything like this?

TarekB3 (author)Topgambling262017-09-28

Hi.
I did an automatic trash can with arduino and ultrasonic senssor, it would be the same, when cat gets near senssor, motor willopen dispenssor and let fall few drops evertime

eladarling made it! (author)2017-07-07

Seeking advice:

I am having some issues with the wheel getting jammed when too many treats fall into it. I tried to see if I could use something like servo.read to detect the location of the servo and reset it back to the "fill" angle if it doesn't make the full rotation to "empty" to try to account for that but I believe servo.read will only detect that last position value sent to the servo, which wouldn't help in this case.

I'm designing it to be activated by a switch online rather than at a timed interval so I want to make sure that whenever the switch is hit, the treats dispense rather than jamming the machine. Any guidance would be appreciated!

Photos attached. Let's be honest here, aesthetics aren't it's best feature but I'm still proud of it.

issca (author)2017-03-19

Hi, have you the wiring schematic also, could i get it. Thanks so much.

webbased (author)2017-03-09

Does anyone have the "Timer.h" Code?

FilipeF18 (author)2017-01-20

Can you use a stepper motor? And if so what changes in the cose?

On The 3dge (author)2012-06-12

is it possible to make this dispense once a day say at 8 o'clock and if so what would the code be after this change, i'm a novice when it comes to arduino so i would really have no idea

arduino17 (author)On The 3dge2017-01-01

I would recommend using a DS3231 Arduino real time clock. This allows you to drop food at one or multiple precise times a day (ex: dispense at 8:00pm and 7:00am)

Yes, but you'd probably have to make it a digital timer (not analog with the potentiometer) and you would have to use the time library found at: http://arduino.cc/playground/Code/Time

LM28 (author)crazydeadmoth2016-09-06

Is there a way to get the feeder to drop a variety of portion sizes? Say, anywhere from 1/4 cup to 1cup?

jongscx (author)LM282016-12-20

Make the segment the size of the smallest segment and make each portion a multiple of that size. Then, just have it dispense multiple times depending on how much you want.

If this doesn't work, ask yourself why you need such granular control over pet food portions. Then use a screw-type feed mechanism and a weighing scale...

Doktor Jones (author)LM282016-11-22

I'd say change the thickness (height) of the wheel dividers so that a quarter segment is the largest portion size you wish to drop. If you wish some segments to drop smaller sizes, install filler panels so the quarter segment only accepts a smaller portion size.

what is the longest time that you could run the intervals without having to change the components loads or otherwise do you know how i would incorporate a digital timer into arduino because like i said i have never used it before, thanks

anoushk1828 (author)2016-09-12

how do i adjust the timing

GerardoM37 (author)2016-08-30

Hi, thanks so much for sharing this project. I'm in the works to building this and making my own adjustments here shortly. I did have a question. In Step 5 when you're building the wheel, I'm having a hard time grasping how you attached the wheel element to the actual rotating servo gear. Did you have an X shaped servo arm and glue that the acrylic circular cut out, or did you do this another way?

ZeeshanM8 made it! (author)2016-05-26

Am from pakistan doing computer sciences in UET TAXILA. I wanna say that thanks alot for such a good idea :) i made it as a fourth semester project :) my design is a little bit different :) tanks alot :) :) <3 dear <3<3

Techgeek2016 (author)2016-04-27

Any help making this respond to email?

sirmaow (author)2016-03-20

im sorry can u make it without using potentiometer ???

Techgeek2016 (author)sirmaow2016-03-21

Yes

sirmaow (author)2016-03-20

im sorry can u make it without using potentiometer ???

JacobW47 (author)2016-02-25

Any advice how to interface this with twitter?

spd328 (author)2016-02-10

Great project and just what I've been looking for!

I am a complete newbie to arduino and am hoping someone can help me out with altering the design to incorporate a timer to facilitate 2 feedings per day (morning and evening). I've been looking around a bit trying to understand the code but I'm in a bit of a time crunch to get this project working so any help would be greatly appreciated!

AfshaanLondhe (author)2015-12-10

this project helped me a lot I wanted to make one but couldnt find a way to dispense the food , untill now!

jasnos (author)2015-12-04

Thanks for great project!

How should I change the code to dispense food twice a day (every 12 hours)?

TimMcD made it! (author)2015-11-14

Thanks for the design! It has worked wonders. Since I live in an apartment I didn't have easy access to saws so I made mine entirely out of cardboard (it doesn't make it look very cool though). I added the "Timer.h" library to your code which allowed me to make the system dispense food at set timed intervals. I only need to find a better way to suspend the feeder over the dish before it is perfect. Once again, thanks a lot for this awesome design!!!

gonzalos5 (author)2015-10-23

hello my name is Gonzalo am from Mexico, very good post I would like to know what the current regulator which is connected to pins 10 and 11

thank you

rkcndy (author)2015-10-08

seems like you could use an actual cd for the wheel, am I right?

alyanaa (author)2015-05-21

can i use micro servo instead of standard servo?

LyannV made it! (author)2015-05-20

Thank you for the instructions! I made this for a school project, and I'm happy with how it turned out! I had some minor issues here and there, but your instructions are very clear. The templates where a huge help too. Keep up the good work! :)

msminnamouse (author)2014-12-20

Have you thought about making adjustments so it can be a remote controlled treat dispenser that will only distribute a treat or two at a time? I train animals and the commercial models are really expensive and prone to jamming.

Dsutton123 (author)2014-11-29

Iv messed with arduino a little bit in the past but Im lost when it comes to "code" I'm trying to figure out how to set timer for every 10 hrs, iv read the other comments but I'm still lost as to where to input the any new code

joyce.wuister (author)2014-09-12

Hi,

I am really interested in making this, but I want it to be an operant task, like the skinner box.
Can I adjust the code so that the treats will only be dispensed after a certain amount of button presses? Like, let's say I want the animal to press the button 5 times before the treats are dispensed.

Thank you in advance

lnicolle (author)joyce.wuister2014-11-02

Joyce, for having built a slightly simpler version based on this design for a different purpose, I can say that yes, the code can easily be modified to do what you want. Or even make the number of pushes random.

In fact it is very flexible. If you do not have programming experience, ask for help here or on Arduino, and you should be able to get people to help.

scotchcollege (author)2014-07-01

Thanks for the detailed response Stuart.

scotchcollege (author)2013-12-08

Can someone please explain the purpose of the potentiometer?

Stuart_F (author)scotchcollege2014-04-30

The potentiometer is used to set the delay in dispensing treats. The relevant code is

for(;potIn>0;potIn=potIn-20)
{
//this is to make the LED flash every 100+potIn miliseconds
digitalWrite(11,HIGH); //set led to on
delay(100+potIn);
digitalWrite(11,LOW); //set led to off
delay(100+potIn);
}

potIn is the value read from the potentiometer (0-1024) at the beginning. So the code works like this:

1) Read potentiometer value (that code is not shown here, but lets say you crank it all the way to 1024

//----------------------------------------start Cycle----------------------------------//

2) Turn LED on

3) Wait 100 + 1024 (value from potentiometer) x milliseconds

4) Turn LED off

5) Wait 100 + 1024 (value from potentiometer) x milliseconds again

6) set the new value from potentiometer as the original value (1024) - 20 or 1004

7) if this new value is greater than 0, go back to step 2 using the new value from step 6.

//----------------------------------------end Cycle----------------------------------//

So basically the code takes the reading once (step 1) and then cycles between steps 2 and 7, subtracting 20 each time until you get to 0 which then triggers the treat to be dispensed.

Cycle 1: potentiometer value = 1024

Cycle 2 potentiometer value - 20 = 1004

Cycle 3: potentiometer value - 40 = 984

....

Cycle N: potentiometer value - 1024 = 0

Dispense treat

The more you turn the potentiometer, the higher the starting value in step 1 (up to 1024) and the longer it takes to get down to 0. I'm not exactly sure why he set it up this way but there you go. Hope that helps.

P.S. In case it's not clear, even though he calls it potIn (and I call it the potentiometer value) in each cycle, that value is only read once prior to the first cycle.

new_freak_tattoo (author)2014-02-06

how can i make to activate it every 8 hours?

demonking (author)2013-05-28

Hey...great tutorial...!
But i want to change the interval to 4 hrs.....?

benekeneb (author)2013-02-02

LIKE!

castillodaru (author)2012-11-13

Hello, I am trying to build this dispenser with my son and have a question regarding the servo wheel. What is the purple part? Do we cut an inner circle also?

zxcvbm (author)2011-11-26

Is it possible to use a DC motor instead of the servo?

mstomel (author)2011-11-13

I want to put multiple treat dispensers that are controlled by a (human controlled) button, is that possible?

CJSudduth (author)2011-09-04

This reminds me of a smaller version of a deer feeder ...

Jeff Broske (author)2011-08-27

THANK YOU !!!

I have been using the arduino for about 2 years now and NEVER seen a tutorial this will constructed and put together.

you are a very good teacher and maker and I appreciate you taking your time to help others.

- Jeff

roncee (author)2011-04-25

That is a very nice work!!!... But can you be able to make it to dispense food two times a day? For example one in the morning and one at night time? Maybe add a timer code to andruino. Is that possible?

crazydeadmoth (author)roncee2011-04-25

yes, you can by using millis(); to figure out how much time has passed in miliseconds since the arduino was swithched on. It'll reset to zero after about 50 days, how ever you could do somethng like this:

startTime = millis()
if(milis() - startTime > 4320000) //12 hours
{
//run the code to drop a treat
}

see this site for a reference: http://arduino.cc/en/Reference/Millis

roncee (author)crazydeadmoth2011-04-25

cool thank you! i will start ordering my arduino and other parts. oh, by the way, i have two dogs (one small and one large) and i have been thinking if i can split the wire to run two servo for individual food servings at the same time. is that possible also?

crazydeadmoth (author)roncee2011-04-25

You sure can. You have two choices here, you could either buy a "Y" servo harness which will split 1 servo output in to to, however the servos will do the exact same thing.

The better option (although slightly more complicated) is to use the Arduino. The Arduino Uno board provides up to 6 PWM (pulse width modulation) signal which means you could control up to 6 servos independently.

You would use the second option like this: in the sample declare the new servo with the code Servo servoName; using the built in Arduino library. Where it says mainServo.attach(3); you would type servoName.attach(pinnumber);

roncee (author)crazydeadmoth2011-04-25

thanks again!

ChrysN (author)2011-02-14

Cool, nicely done!

About This Instructable

135,398views

143favorites

License:

More by crazydeadmoth:Hack/Mod a concave arcade style buttonArduino controled dog food/treat dispenser
Add instructable to: