loading

Milton incorporated presents The Cat Mouse Tower!

Thousands of cats across the nation are now being entertained by this amazing device!

The basic idea behind this toy is a tower that has a motor driven mouse, provided your cat with endless fun. Simply plug the device in and wait for your cat to activate it by walking past the motion sensor! Our device runs for 90 seconds varying through many sequences of spins to confuse and entertain your cat. Once the cycle is done, it will only activate only the motion sensor is tripped again

Step 1: Materials

-1 Arduino UNO board

-Arduino Data Cable/Computer with Arduino software installed

-1 Continuous Servo Motor

-1 Ultra Sonic Sensor

-1/2 inch (1.25cm) thick Ply-Wood

-0.5 cm by 0.5 cm rod of wood

-Carpet Fabric

-1 Cat toy on a string (we used a mouse)

-Staple Gun

-Nails or Screws

-Wood Glue

-Saw (table, circular, hack, electric hand)

-Drill

-Sand Paper/Power Sander

-Tape

-Soldering Iron

-Wires (we used blue)

-3 female to male wire connectors

-1 female to female wire connector

Step 2: Sketches and Measurements

The tower of the cat toy can be made to different sizes, so planning the dimensions ahead of time can make the construction easier. You will want the tower to be tall enough that the cat won't be able to get in the way of the rotating arm, the base wide enough so that the tower won't fall over, the guards for the motor tall enough that the motor is protected, and the arm on the motor long enough to make sure the toy doesn't get stuck along the edge of the tower. The dimensions used in our version have the base as 25cm x 25cm, the tower as 10cm x 10cm x 25cm (with 2 10cmx25cm and 2 7.5cmx25cm sides), the motor guard as 10cmx10cmx3cm (with 2 10cmx3cm and 2 8cmx3cm sides), and the motor arm as 7cm (we recommend 1 or 2 cm longer). The pieces are cut from the 1.25cm thick ply-wood we used and the arm is cut from the 0.5cmx0.5cm rod. We also used the rod to help secure the motor, although we didn't want a permanent solution.

Step 3: Putting Together the Tower

Once you have determined your desired measurements, measure and draw the outline of each piece on the wood and cut out the pieces (note that the saw will eat up some of the wood, so don't have the pieces lined up right next to each other, or the measurements will be incorrect after cutting). You can use a circular saw, table saw, and or a hack saw to cut your parts. Towards the bottom of one of the walls measure and cut two circular holes to fit the ultrasonic sensor. Also a hole should be cut in the base to allow a place for the circuitry to be setup. This can be done later once the main part of the tower has been created.

Then using glue/a hammer and nails, put together the wall pieces of the tower. Now attach the top of the tower to the tower walls, and on top attach the motor guards. Then in the top piece of the tower using where you want the motor to sit as a guide to drill a hole for the wires of the servo motor. Now cut a square hole in the middle of your base piece to the exact size of the interior of the tower, and attach the tower to the base.

Then cut the carpet fabric the the size of all the walls and base of the tower, and use a staple gun to attach it (however you don't need to put carpet fabric within the motor guards, as the cat is unlikely to be able to reach there), and make sure to cut a hole in the fabric so it won't cover up the holes for the ultrasonic sensor.

Now secure the motor to the top of the tower and put the wires through the hole so they are on the interior of the tower. Attach the arm to the servo using screws or tape, and attach the toy to the arm using string. We attached our servo motor by using more 1cm by 1cm wooden rod and tape to make it sit in place, screws however are a more permanent solution. You can also test your ultrasonic sensor and make sure it fits in the holes you drilled.

Step 4: Writing Your Software

You will need the arduino IDE on your computer in order to upload this program to the arduino. Here is the code we used to program the arduino for the purpose of this toy. This code can be altered to have the toy turn on at different distances from the sensor, and to make the pattern of the motor different. To change the distance detected by the sensors, change the number highlighted blue (the number represents how many centimeters the sensor will detect). The code highlighted yellow is the pattern of the motor, and it can be completely remade, with the following instructions:

type: myservo.write(20); The number in the brackets determines the speed and direction of the motor, 20 is not moving at all, from 20 to -140 is one direction with the motor moving faster at -140, and from 20 to 180 is the other direction with the motor moving faster at 180.

then type: delay(200); The number in the brackets determines how long in milliseconds the servo will spin for at the speed specified beforehand (there are 1000 milliseconds in 1 second).

Write as many combinations of these commands as you want, but end the pattern with: myservo.write(20); so the motor will stop until the sensor is triggered again. Otherwise the motor would spin endlessly.

Original Code Link: https://docs.google.com/document/d/1D5Ww5ysLC3rmok...

If you don't want to write your own code you can copy and paste the following lines:

/************************************************/
#include //Allows servo library to be used so the servo motor can be controlled /************************************************/

Servo myservo;//sets up the servo object as myservo

int trigPin = 10;//sets up pin that triggers the motion sensor to send out a reading

int echoPin = 11;//sets up pin that sends out the motion sensors pulse

long duration, cm;//sets up centimeters as the used measurement

/************************************************/

void setup()//sets up pin directions and sets the servo to not move {

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

myservo.attach(9);

myservo.write(20);//sets continuous servo motor so it doesn't spin }

/*************************************************/

void loop() { //the below code activates a pulse on the proximity sensor and stores how long the pulse took to return to the sensor

digitalWrite(trigPin, LOW);

delayMicroseconds(5);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10); //the transition from low to high on the trigger pin activates the pulse

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);//detects the time the pulse took to return to the sensor

cm = (duration/2)/29.1;//converts the time of the pulse into centimetres

delay(250);

if(cm<20)//checks if cat is within 20 cm {

//the following code makes servo spin at a certain speed where less than 20 is one direction, and more than 20 is the other direction

//the farther away from 20 the write value is, the faster the servo will spin

//if the servo is written to 20 the servo will not spin

//the delay command then states in milliseconds how long the servo will spin for at that speed

//the following code is a collection of commands that make the servo spin back and forth at different speeds

myservo.write(-20);

delay(10000);

myservo.write(60);

delay(10000);

myservo.write(-80);

delay(10000);

myservo.write(120);

delay(10000);

myservo.write(-140);

delay(10000);

myservo.write(180);

delay(10000);

myservo.write(-80);

delay(2000);

myservo.write(120);

delay(2000);

myservo.write(-140);

delay(3000);

myservo.write(60);

delay(3000);

myservo.write(180);

delay(3000);

myservo.write(20);

delay(2000);

myservo.write(60);

delay(2000);

myservo.write(120);

delay(2000);

myservo.write(180);

delay(2000);

myservo.write(-80);

delay(3000);

myservo.write(180);

delay(3000);

myservo.write(-140);

delay(3000);

myservo.write(20);//sets continuous servo motor so it doesn't spin

} //(Should only be tabbed in once)

} //(Shouldn't be tabbed in)

/**************************************************/

Step 5: Circuitry and Hardware

Use the male to female connectors to connect the trigger, echo, and ground pins of the ultrasonic sensor to pin 10, pin 11, and ground on the arduino respectively.

Now strip some of the middle of a wire and solder another wire onto it to create a three ended wire. Use one end of this wire to plug into the 5v on the arduino, and one of the other ends to connect to the vcc on the ultrasonic sensor via the female to female connector. The third end of this wire goes into the positive voltage (red wire) of the servo motor, then use other wires to connect the ground (black wire) and input (white wire) of the continuous servo to ground, and pin 9 on the arduino.

Using a USB cable, upload your program to the arduino, and after it finishes uploading, unplug the cable and plug in the wall plug adapter into the arduino. Now secure the ultrasonic sensor in the holes in the wall of the tower, and secure the arduino inside the tower as well. Now plug in the plug and the sensor will start the motor when it detects motion within the programmed range.

<p>That's a fun design :)</p>

About This Instructable

94views

4favorites

License:

More by MichaelW650:The Cat Mouse Tower 
Add instructable to: