Making a Custom Cat Toy Using Arduino Uno and a Metal Bowl
by arinakd in Circuits > Arduino
1570 Views, 10 Favorites, 0 Comments
Making a Custom Cat Toy Using Arduino Uno and a Metal Bowl
What is this project about?
For a school project, I basically made a Roomba with a cat toy attached for my cats Juno and Aiko. Powered by a 9V battery and the will of God, this mouse-bot can accurately detect distances with the use of a sonar module. If it gets too close to a wall or nearby object, one of its wheels will stop spinning, so it can move directions and continue on its journey of entertaining (or rather terrifying) the cats.
I came up with this idea mostly so my cats have something to play with when they're feeling bored or are hyperactive.
Looking back
I would've never guessed I would be able to make my own robot. It was very overwhelming, seeing as I'm not technologically savvy at all. I have little experience in coding, and had a hard time grasping how all the circuits worked. All in all, I'm very pleased with how it turned out!
List of tutorials used
- How to control a DC motor with L298N driver and Arduino Uno
- Arduino Robot Car with Speed Sensors - Using Arduino Interrupts
- Using the HC-SR04 Ultrasonic Distance Sensor with Arduino - Everything you need to know!
- Self Balancing round shape robot Car for arduino Assemble kit tutorial step by step
- Arduino Robot Car | Obstacle Avoiding Robot Car 2WD with Ultrasonic sensor and L298N Module
- How To Make Arduino Obstacle avoiding Robot | L298N Motor Driver | 4 Wheel Chassis Kit | Sinhala
Supplies
Car kit
- Arduino Uno Rev3
- L298N DC-Motor Controller
- Ultrasonic Sensor - HC-SR04
- Round DIY Car Kit, which includes:
1x Top mounting plate
1x Lower mounting plate
2x Motor (click here for specifications)
2x Wheel (click here for specifications)
2x Swivel Wheel
2x Light slot wheel (allows you to measure the speed with a light slot sensor)
2x 1xAA Battery Holder or 1x 2xAA Battery Holder (in series for 3V total)
4x Motor mount piece
4x Spacer - 30mm
8x Spacer - 10mm
8x Bolt with flange - M3 - 5mm (or 10mm)
4x Bolt - M3 - 10mm
16x Nut - M3
- 9V Battery (instead of the AA batteries that are included in the car kit)
Mouse exterior
- Metal bowl Ø 20 cm
- Glue gun
- Pattex Contact liquid glue
- Gold Spray paint
- PVC Tube diameter Ø11cm, 2 cm in length
- Sandpaper 80 grit
- Plastic, thin flower pots
- Black permanent marker
- Wired cat toy of choice
Equipment
- Drill with a 20 mm bit
- Scissors
- Soldering iron
- Solder wire
Circuit Assembly
For the first step, I wanted to showcase the internal components of the cat toy. The circuit consists of six key components: an Arduino Uno, an ultrasonic sensor, two DC-geared motors, a motor driver module, a 9V battery, and an on/off switch. The 9V battery serves as the power source for this structure. I opted for a 9V battery instead of the AA batteries included in the car kit, so the car drives faster..
With a lot of help from a friend and watching a lot of tutorials, this circuit worked!
The challenging parts of this was reconstructing it to fit the car kit.
Code
#define TRIG 2
#define ECHO 3
int In1 = 7; // Pin number for motor IN1
int In2 = 8; // Pin number for motor IN2
int ENA = 5; // Pin number for motor ENA (speed control)
int In3 = 12; // Pin number for motor IN3
int In4 = 13; // Pin number for motor IN4
int ENB = 9; // Pin number for motor ENB (speed control)
int SPEED = 210; // Speed value for the motors
float distance; // Variable to store the measured distance
void setup() {
//Setup code
pinMode(In1, OUTPUT);
pinMode(In2, OUTPUT);
pinMode(ENA, OUTPUT);
pinMode(In3, OUTPUT);
pinMode(In4, OUTPUT);
pinMode(ENB, OUTPUT);
Serial.begin(9600);
pinMode(TRIG, OUTPUT); // Set the TRIG pin as an output
pinMode(ECHO, INPUT); // Set the ECHO pin as an input
start_driving();
}
void loop() {
// Main code
check_distance();
check_for_walls();
// Serial.print("distance");
// You can use the line above to see if the ultrasonic sensor is accurately measuring the distance
}
void check_distance() {
// This function calculates the distance using an ultrasonic sensor and determines the "reaction time" when one wheel needs to stop spinning after reaching a distance of <= 15 cm
digitalWrite(TRIG, LOW);
delayMicroseconds(2);
digitalWrite(TRIG, HIGH);
delayMicroseconds(5);
digitalWrite(TRIG, LOW);
float t = pulseIn(ECHO, HIGH); // Measures the duration of a pulse from the ultrasonic sensor
float distance_2 = t * 0.017015; // Converts the duration of each pulse to distance in centimeters (assumes the speed of sound is 343 meters per second)
distance = distance_2;
Serial.print("Distance: ");
Serial.println(distance);
delay(10);
}
void check_for_walls() {
// This function checks if there is a wall nearby based on the measured distance
if (distance <= 15) {
digitalWrite(In3, LOW); // If the distance of a nearby object/wall is less than or equal to 15 cm, one wheel stops spinning to change the robot's trajectory
}
if (distance > 15) {
digitalWrite(In3, HIGH); // If the distance is more than 15 cm, this wheel starts spinning again to continue going straight
}
}
void start_driving() {
// This function sets the motor pins to control the direction of the DC geared motors and starts driving
// Depending on how you connect the motors to your driver module, you'll need to decide which pins are set to HIGH and which are set to LOW
// This is to make sure both wheels spin in the same direction
digitalWrite(In1, HIGH);
digitalWrite(In2, LOW);
analogWrite(ENA, SPEED);
digitalWrite(In3, HIGH);
digitalWrite(In4, LOW);
analogWrite(ENB, SPEED);
}
In the attachments you'll find the arduino code file.
Downloads
Soldering
For this step, I soldered the battery to the on-off switch. Unfortunately, I couldn't obtain a 9V battery holder in time, so I attempted to solder directly onto the battery. Please note that this approach is not recommended, as the solder did not properly adhere to the battery. As a solution, I had to use tape to secure the connection. If you plan to recreate this project, I highly recommend acquiring a battery holder beforehand.
To proceed with the soldering, connect the positive side of the battery to the OFF side of the switch. The ON side of the switch should be soldered to a separate wire, which will then be connected to the GND pin on the driver module. The negative side of the battery should be connected to the 12V pin on the driver module.
To securely connect the DC-geared motors, solder the wires onto the corresponding receivers as indicated in the circuit assembly sketch from the first step
Assembly: Car Kit and Circuits
For this step, you will assemble the circuits you have prepared so far to fit the round car kit. Start by following this tutorial to assemble the first part of the car, but do not add the second layer yet. On the first layer, secure your Arduino, driver module, and 9V battery. I made a sketch to illustrate the positioning of these components.
Once you have completed that, you can proceed with the tutorial. To connect the Arduino Uno with the ultrasonic sensor, you can route the wires through the long openings on the front side of the car. Refer to the pictures for an example of how this can be done.
Additionally, I have attached a cat toy to the swivel wheel on the backside.
Making the Exterior
My initial plan for the encasement was to 3D print a mouse exterior. I ended up not going through with this due to lack of time, so I had to improvise. My next option was using a metal bowl for the exterior, and attaching a gray pillow cover on the outside, so it'll have the appearance of a mouse. This didn't end up working as well, because the pillow cover wouldn't attach securely. I decided to spray paint the bowl and drill 'eye' holes for the ultrasonic sensor instead.
First, I had to drill holes for the sensor. I put the bowl on the car kit itself, and measured the position of where the hole should be. The bowl itself was 20 cm in diameter, and around 9 cm in length. First, I made a hole around the 7 cm height mark. The entire hole ended up being 5 cm long and 2 cm wide. The holes were made using a drill with a 2CM bit.
Next, to prepare the bowl for spray-painting, I used 80 grit sandpaper to sand the outside of the bowl, and spray-painted it gold. Leave it to dry for about two hours.
For the mouse ears, I grabbed some old plastic flower pots and cut out two oval shapes, and painted these gold too. To secure them, I used a glue gun. After the glue cooled off, I spray-painted the exterior one last time. I also took the wheels off, and spray-painted the yellow part gold to fit the rest. This step is optional.
When I put the exterior on the circuit, I figured it would be hard to secure it and make sure it sticks together. When I tested the circuit, I also noticed that the bowl tended to shift a lot and obscured part of the sensor, making it hard for the circuit to do what it's intended to.
To solve this, I grabbed a PVC Tube with a diameter of 11, and cut it to about 2 cm in length. I secured it in the middle of my circuit with hot glue, and let it cool off.
I secured the circuit to the bowl by using hot glue on the top part of the PVC tube, and quickly placing the metal bowl on top.
Draw the Mouse
For the last finishing touch, draw a mouse face on the metal bowl. That's about all it takes to make this circuit!
If you decide to recreate this, I hope your cats will enjoy it as much as mine do. :)