Dog Treat Trainer

by CarolineB45 in Circuits > Arduino

1096 Views, 9 Favorites, 0 Comments

Dog Treat Trainer

Dog Treat Dispenser
IMG_3505.jpg

My project builds a dog treat dispenser that gives out a few treats at a time. It uses a remote control (even your normal TV remote if you want!) to dispense treats. It includes an optional LED to show when the treat is coming. I picked this because most dog feeding machines are to feed your dog an entire meal. This one only gives out treats. It can be used as a training tool, because I bet your dog will sit in front of it for a long time waiting…s/he/they can practice stay! You can also get your dog away from you by giving out a treat. They will come running when they hear the beep once they know it means treats!

This is meant for the advanced user.

Supplies

  • arduino controller
  • breadboard
  • micro servo motor
  • IR receiver
  • remote control
  • active buzzer*
  • LED and 330 resistor (optional)
  • 10-11 jumper wires
  • dog/cat treats; respective pet
  • ramp components

*a passive buzzer uses tone(), which conflicts with the IRremote library. There is a workaround for this, but it is more complicated!

Schematic/Set Up

fritz diagram.JPG

Connect your LED (if desired) to pin 9 using a 330 resistor.

Connect your active buzzer to pin 6.

Connect the IR receiver to pin 10. Mine is connected to its own breakout board with the pins labeled by letters: G = ground; R = power; Y = signal. Use this page to troubleshoot your IR receiver hookup.

Connect the Servo motor, matching black to ground, red to 5V, and orange to a digital pin (I used 11). Use this page to troubleshoot your Servo hookup.

Find the Codes for Your Remote

IMG_3501.jpg

You can use a remote dedicated to the Arduino, or use your regular TV remote! I picked one of the random buttons on my remote that doesn't have much of a purpose and used that (the blue one at the bottom). That way, I can watch TV and treat my dog from my comfy spot on the couch!

Use this tutorial to find the codes for your remote.

Basically, upload the following code:

#include <IRremote.h>

const int RECV_PIN = 7;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup(){
  Serial.begin(9600);
  irrecv.enableIRIn();
  irrecv.blink13(true);
}

void loop(){
  if (irrecv.decode(&results)){
        Serial.println(results.value, HEX);
        irrecv.resume();
  }
}

Press a button and see what the value is in the serial monitor.

Save this to put into the code in step 4.

Construct a Ramp

IMG_3506.jpg
IMG_3504.jpg

Use whatever you have on hand to build a slanted chute for your treats. Maybe two rulers taped together to form a chute? Legos? Play around with the angle of the ramp and how many treats you load in at once.

I used a PVC tube for the chute and a pill bottle to lift one end into the air, which has the added bonus of holding more treats for later. I taped all this together with duct tape, and also taped the Servo motor to the edge of the table top. The tape keeps all the parts from sliding around.

The Code/Putting It All Together

IMG_3503.jpg

You can download the code file, view it below, or view it on create.arduino.cc by clicking here. Line 22 is where you will put your code for the remote button you want to use. Write "case 0xCODE:" and replace CODE with your remote button code.

#include <IRremote.h> // add the library for the IR receiver
#include <Servo.h> // add the library for the Servo motor

const int RECV_PIN = 10;
IRrecv irrecv(RECV_PIN);
decode_results results; // lines 4-6 setup the IR receiver
const int LED = 9;
const int buzzerPin = 6;
Servo myservo; // name the servo
int pos = 0; // variable that stores the servo position

void setup(){
  irrecv.enableIRIn(); // IR receiver setup
  pinMode(LED, OUTPUT); 
  pinMode(buzzerPin, OUTPUT); 
  myservo.attach(11); // the pin where your servo is attached
}

void loop(){
  if (irrecv.decode(&results)){
  switch(results.value){ // 20-21 IR receiver setup
    case 0x20DF8679: // this is where you put the code for the remote button
      digitalWrite(LED, HIGH); 
      digitalWrite(buzzerPin, HIGH);
      delay(20);
      digitalWrite(buzzerPin, LOW); // lines 24-26 give a short note before the servo moves
      for(pos = 0; pos <=180; pos +=1){ 
        myservo.write(pos);
        delay(10);
      }
      for(pos = 180; pos>=0; pos-=1)
      {
        myservo.write(pos);
        delay(10); 
      } // lines 27-35 control the servo movement
      delay(2000);
      digitalWrite(LED, LOW);
      } 
    irrecv.resume(); 
    }
}

Downloads

Conclusion

IMG_3499.jpg

Hopefully you can follow this tutorial. Have fun making a treat device for your furry friend(s) to enjoy!

A special thanks to my dog Molly for participating in my video even though she had an upset stomach and didn't really want treats.