Introduction: Cat & Mouse Play Toy

OVERVIEW:

"Cat & Mouse Play Toy" is a toy specially designed for cats. It has several components that make play time for cats exciting and rewarding. The "toy box" sits on the ground and has a motorized mouse inside, ready to run. In order for the cat to release the motorized mouse it must first play with a hanging toy with a photo resistor behind it. Once it plays with this toy the mouse is released. If the cat can catch this mouse while it runs around the room and dodges obstacles, it will make a buzzing noise and the toy box spins to reveal cat food for the cat. There are several thing you will need to make this toy.

Required supplies:
1. PetSafe 5 Meal Automatic Pet Feeder from Petsmart
2. SmartyKat Motion Madness Motorized Cat Toy found at Target
3. One miscellaneous toy that can dangle
4. Arduino
5. Photo Resistor
6. Electret Microphone complete with Breakout Board
7. Conductive Fabric
8. Soldering Iron
9. Solder
10. Wire
11. Wire Cutters
12. Electrical tape
13. Saw
14. Duck-tape
15. Screwdriver
16. 4 D batteries
17. 2 small 3V batteries
18. 5K resistor
19. Super Glue
20. Something to hide those loose wires in
21. Treats for the kitty

Step 1: Making the "Toy Box"

Part 1:
To create the toy box we took our automatic cat feeder and unscrewed the battery and timer section of it. Inside this section there is the circuit that controls the timer. It should have 4 wires: yellow, green, brown, and orange. Strip a part of the plastic from the brown and green wires so the wire inside is exposed. Next cut a wire of reasonable length and solder it to the now exposed section of the green wire. Do the same thing for the brown wire. Now use the soldered wire to connect the brown wire to the ground peg of the arduino and the green wire to the arduino's digital peg 2. The reason for this is to allow us to control the automatic feeder from the digital peg 2. So instead of rotating when the timer sends a signal the device will now rotate when digital peg 2 sends a signal to the device.

Part 2:
Now that we have rewired the feeder, we will saw off some of the edges. WARNING: This step of the project is dangerous and can result in injury if the tools are not used properly. First remove the rotating bowls from the container. Then remove the lid from the container. there are two hinges holding it on and you can simply pop it off of those. Once both parts are removed we can get to sawing. Saw off the front edge of the lid so that the triangle opening on the top now extends down the side. Once that is done it is time to saw the rotating bowls. This part is fairly difficult so be careful. We want to saw off the outside wall of one of the bowls so that our mouse can escape from it. Now that this is done make sure to make a ramp from the box to the ground so the mouse doesn't fall out of the box and onto its side.


Now that the edges are sawed and the timer is rewired we have successfully made our "Toy Box."

Step 2: Making the Mouse

Part 1:
To add the buzzer to the mouse we need our 3V batteries and the buzzer. First we remove the blue fabric from the mouse so the only thing left is the hard shell of the mouse. Next we but the 2 3 Volt batteries in series and attach the black wire from the buzzer to the negative end of the batteries. Next we cut a piece of wire and attached it to the positive end of the batteries. We did all of this by simply wrapping electrical tape around the batteries and wires. (Note: if you touch the red wire from the buzzer to the wire from the positive end of the batteries you should hear a buzzing noise. If not, you have done something wrong.) Now we strip the plastic off the red wire. If you are lucky it will have multiple little wires inside that you can feather out. If not, you will have to solder several exposed wires to the red wire so they can be feathered out over the back of the mouse. once this is done we attached the batteries to the front of the mouse and the buzzer to the back of the mouse. Be careful not to cover the hole of the buzzer or the sound will be muted. Also, do not cover the feathered wires or the open wire from the positive end of the battery.

Part 2:
This part of step 2 has some flexibility since it is primarily customizing the look of the mouse. However, it is important that the mouse is covered in conductive fabric. We chose to only use the face and tail feathers from the original mouse covering. You can do exactly as we did or you can use none of the original mouse fabric. Just make sure that when you are decorating your mouse that you do not cover up the hole in the buzzer and you keep the feathered wires and the open wire from the battery exposed. Once your mouse looks how you want it you will add your conductive fabric. cut a piece of conductive fabric large enough to cover the entire surface of your mouses back. Attach the fabric to your mouse using super glue. Now attach the wire from the battery to the conductive fabric. We did this by securing the wire in place under the fabric so they will always be touching. Now feather out the stray wires from the buzzer over the back of the mouse so they are just barely above the conductive fabric. press down on them so they're touching the fabric this will connect the circuit and the buzzer will sound. If not, something has gone wrong and you will need to look back over your mouse. 

Step 3: Adding the Sensors

Part 1:
First we will add the photo resistor to the arduino. First cut a wire about a foot long and solder it to one peg of the photo resistor. Do the same for the other peg. Now connect one of the wires to the 5V peg on the arduino. Next, solder the 5K resistor to the other wire coming from the photo resistor. Make sure the end with the gold stripe is attached to the wire from the photo resistor. Solder wires to both ends of the resistor. Connect the wire from the end of the resistor with a gold stripe to the arduino's analog 3 peg. Connect the wire from the other end of the 5K resistor to the ground peg of the arduino.

Part 2:
Now we will add the microphone to the arduino. This part is simple since the microphone comes with a breakout board. The breakout board will have 3 pegs: GND, VCC, and AUD. We connect GND to the ground peg of the arduino. The VCC peg should be connected to the 5V peg on the arduino. Since the photo resistor is already using that spot you can solder the 5V wires for the photo resistor and the microphone together so you can connect them both to the 5V peg on the arduino at the same time. Finally we connect the AUD peg from the microphone th the analog 5 pin on the arduino. Now that the microphone is successfully hooked up we can input values from it.

Now all individual components of your play toy are hooked up properly.

Step 4: Coding and Setup

Now that the project is fully put together its time to write the code and set it up. First you will want to install Processing and Arduino on your computer if you haven't already. Once those are installed you can start coding.

Here is our code:

**********Code Starts Below This Line*******

int potPin = 3; //photoresistor pin 
int motorPin = 2; //motor pin
int mic = 5; //microphone pin

void setup()
{
  Serial.begin(9600);
  pinMode(motorPin, OUTPUT);
}

void loop()
{
  int reading = analogRead(potPin); //getting the values from the photoresistor
   Serial.print("Light: ");
   Serial.println(reading);
  if (reading > 150) { //if there is a lot of light rotate the feeder
    digitalWrite(motorPin , LOW);
    Serial.print("Light: ");
    Serial.println(reading);
  }
  else{ //otherwise run "avg()"
    avg();
  }
}

void avg(){
  float volume = 0; //volume picked up from the sensor so far
  float count = 0; // number of samples in the average so far
  float big = 0; //biggest value picked up
  float little = 1023; //smallest value picked up
  float noise = 0; //each value from the sensor
  while (count < 500){ //getting the average, biggest, and smalles values
    noise = analogRead(mic);
    volume = volume + noise;
    count ++;
    if (noise < little){
      little = noise;
    }
    if (noise > big){
      big = noise;
    }
  }
  int diff = big- little; //difference between the largest and smallest values
  Serial.println(diff);
  if (diff > 225){ //if there is a big difference in noise rorate the feeder
    digitalWrite(motorPin, LOW);
    Serial.println("BOOOOOOOOOOOOOOOOOOOOOOOOMMMMMMMMMMM");
  }
  else{ //otherwise leave it alone
    digitalWrite(motorPin, HIGH);
  }
}

*****Code Ends Above This Line************

For setup you will want to place the toy box on the ground so the mouse will be able to escape. You'll also want to hide all of those stray wires in a box so they don't get tangled. Make sure there is a surface to hang the dangling toy off of. We used a chair. Tape the photo resistor to whatever surface you will be using so it will be behind the toy when you dangle the toy from the surface. Now all that you need to do is upload the code to the Arduino and leave it plugged in to the computer and it will be ready to use!



Possible improvements for the future:

We are open to any new ideas or improvements for this toy. One way it can be altered is by using more mice to complicate the interaction with the cat. Instead of spinning after the mouse has been caught and cat food is revealed, another mouse can be revealed and escape for the cat to catch. Another idea for the future is using "FFT" to make the microphone pitch sensitive so it can only pick up the sound of the buzzer.