Sad Cat Fixer

by 1004360 in Circuits > Arduino

222 Views, 1 Favorites, 0 Comments

Sad Cat Fixer

FAI0IENKDOJ2047.png

It is important to give our feline family members the opportunity to express their natural behavior through play. Along with satisfying your cat’s natural instincts, interactive play is important to help keep your pet healthy and happy and this is exactly what this toy does.

Supplies

1) Arduino Uno: Brains of the operation

2) Ultrasonic Sensor HC SR04: Eyes of the operation

3) LN298 Motor Driver: To drive the motor

4) A DC Motor: The muscles of the operation

5) Wooden Boards

6) Wooden dowels

7) Some string

8) Your Cat's Favourite toy

9) A 12v battery source

10) A motor Coupler

11) Basic tools and glue

Making the Housing for Your Toy

FCKNBGUKDN3N6VE.png
FFJWNGDKDOJ2023 (2).png
FZ6RIK6KDOJ2026 (3).png
F45ZAOPKDOJ2027 (2).png

First, we need to make the housing that holds everything together. It is made up of 4 different pieces: The top, the backboard, and two side panels.

The backboard is a simple rectangular piece of wood of size 30 by 15 cm with a 45-degree bevel on one edge. The top board is 30 by 15, but with a slit, twice the diameter of the wooden dowel cut onto one side, with a 45-degree bevel on both edges perpendicular to the slit. Both the side pieces are right-angle triangular pieces with perpendicular sides being 15 by 15 cm. They both have a hole slightly bigger than the wooden dowel diameter. One of the side pieces also has a small protruding wooden piece slightly lower and offset to the front from the hole. This piece acts as a stopper to prevent the arm mechanism from falling down.

Creating the Inner Mechanism

F7NUH7GKDOJ202A (2).png
FRDPFOAKDOJ202B (2).png

We now want to make the arm that is attached to the motor and also has the toy attached to it.

First, attach a 30 cm piece of dowel to your motor by using an appropriately sized coupler, then, place the end of the motor along the inner face of the side piece and mark out how many dowels you would need to place it inside the hole in the opposite side panel.

Now, mark out where the slit on the upper panel is, and drill a hole into the side of the dowel, to insert another 35 cm dowel. This will be what the toy attaches to.

Next, similarly, insert a small dowel into the main dowel so that it rests on the support piece of the main body keeping the toy arm parallel to the ground as shown. Do not attach the motor to the frame yet. first, we will configure the electronics and then comes assembly time.

Electronic Portion

2022-01-20 (3).png

The image shown is the setup I used, however, I will explain a simpler method using the l298n motor driver board, rather than the IC.

We are going to use an Arduino Uno as the brains, and an ultrasonic sensor as the eyes. First, we will supply 12 v to the l298n motor driver. the motor driver will have a 5v output pin, which we will use to power the Arduino and the ultrasonic sensor and use a common ground.

Next, connect the motor terminals to the output pins of the driver. Then, connect one of the enable pins of the motor driver to pin 4 of the Uno, and the other enable pin of the motor driver to the ground. So, if we put pin 4 of Arduino high, then the motor will spin in one direction.

Finally, the ultrasonic sensor's trigger pin is connected to pin 2, which will be used to send a pulse out and the echo pin is connected to pin 3 of Arduino and will be used to read the echo to locate an object.

Code

So what this code essentially does is it checks if the cat has jumped to grab the toy or not. if the cat has jumped, then the ultrasonic distance sensor will sense it and it will send a signal to the Arduino. then we pulse the motor so that the arm goes up taking the toy with it.

Here is the code:

//Variables
const int trigPin = 2;

const int echoPin = 3;

const int motorPin = 4;

float duration, distance;

void setup()

{

//setting up the pins as output or input

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

pinMode(motorPin, OUTPUT);

}

void loop()

{

//we want to make sure that the trigger pin is low before we trigger it as high

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

//we set the trigger pin as high to send a pulse out

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

// again we set it as low

digitalWrite(trigPin, LOW);

// to detect the time of returned pulse, we use pulseIN to see for how long the echopin is at HIGH

duration = pulseIn(echoPin, HIGH);

// distance will be equal to time x speed of sound divided by 2 as the pulse has to go to the object and comeback

distance = ((duration*.0343)/2);

delay(100);

//condition to triger motor. Fine tune this value to trigger it just below the toy.

if( distance < 45 )

{

//enabling motor for 2000 ms

digitalWrite(motorPin ,HIGH);

delay(2000);

//disabling motor

digitalWrite(motorPin ,LOW);

//delay the loop for 5 seconds to allow the rod to settle

delay(5000);

}

}

Assembling the Toy

FGIO7Q7KDOJ202I (2).png
F45DT6JKDOJ202L (2).png

First, find a space on the wall that is not too high.

Mount the housing onto the wall using some screws. then, put in the motor and dowel arm assembly carefully, and make sure it stays parallel to the floor.

Then, put the toy on a string and hang it from the arm at an appropriate height so that the cat can see it and jump for it. now, stick the ultrasonic sensor 5-10 cm below the toy so that it can detect the cat before it reaches the toy.

Finally, put the Arduino, battery, and the motor driver on top of the housing and wire everything up. To prevent the arm from banging into the housing, use a piece of sponge or foam on the backboard where it might touch it and also on the support to prevent noise.

Circuit Diagram

2022-01-20 (4).png

This is a circuit diagram of the circuit used in the toy.

Testing and Fine Tuning

FE0HLT4KDOJ202K (2).png

First, make sure that the Ultrasonic sensor is below the toy as we don't want it to trigger itself.

Then, manually trigger it to see what happens. If the arm goes up perfectly, amazing! No tuning required! if the arm goes up too much, and hits the board or the wall, reduce this value a bit.

digitalWrite(motorPin ,HIGH);delay(2000);

If alternatively, the motor is not going up enough, then increase this value a bit. make sure to do it in steps of 50 or 100.

Then, It's done! let your cat loose and enjoy some funny cat moments!