Introduction: Cat Playing Toy

Hello everyone!

My name is Wouter and I'm a student of Mechanical Engineering at the Hogeschool Rotterdam. As we get to follow courses of our own choices, this is my assignment for the course "Smart Objects". In this instructable I will explain the way I designed and realized a playing toy for my cat.

To get a grade for this assignment there is a playing rule: I have to use a 3D-printer and/or a lasercutter. My choice will be explained in the first step of this instructable.

Step 1: The Idea and the Delovoping Proces

The idea emerged from the fact that I have a very playful cat that needs to be entertained at almost all the times. Just before the start of this course I had bought a regular laser toy that needs to be operated by hand. He really likes it, so the idea to make an automatic toy that can run without me came very soon afterward.

The first part in the proces of creating such a toy is making choises on what has to be included and what not. The first idea that came to my mind was to create a laser system that reacts to the cat drinking (enough) water. As I advanced in searching the right components for my Arduino my teacher and I came to the conclusion that the needed sensors were not precise and reliable enough to use. At this point I decided to take a step back from measuring the amount of water that was drunk by the cat, and began to think of different solvations for this problem. The most efficient way to detect a cat is just to 'see' him with a sensor. So, the search on the internet continued and I came across an UltraSone-sensor that could tell the difference from 0 [cm] to 100 [cm] really welll and thus it was exactly what I needed.

The second part is controlling the laser in such a way that it can move in multiple directions. The most obvious way to do this is with two servo's connected to my arduino. Because I don't want to copy any ideas from the internet I didn't google the easiest way to get two servo's to move in two directions (with two directions I mean a horizontal and a vertical movement). At this point the part that I have to use a 3D printer or lasercutter comes very handy. Luckily I have some skills with Autodesk Inventor so I desgined a holder for my two servo's and printed it. The printed part is showed in one of the figures above.

To cover up the arduino and for protaction sake from the cat I used a box as an housing for the system. The box is a simple cilindric box that can be bought in almost every house-decoration store. I decided to do this instead of lasercutting, because it is a lot more efficient to edit and it is cheaper too! I also think that when I'd lasercut a box, the layout would just be a from "makercase.com" so it wouldn't be a really added value. The box is showed in one of the figures above. One of the earlier sketches of the product is showed in the figures above.

There are also some more things that I left out of the project. Here is a list of the things and behind them are the reasons I left them out. (That shouldn't mean that you should let them out too!)

  • A treating system. There are two main reasons I left this one out. The first one is that it would probably need another motor to drive the system. For the current setup there are already 8 AA battery's and a powerbank needed to run it, so I think I'd be too much to keep adding power sources. The second reason is, I don't want to get my cat fat.
  • Detecting the cat with a weight sensor. This is a spin off of the drinking system and is left out for the same reason; not realiable and precise. ( Well they can be, but I'd get to expensive for such a simple project. )
  • Sound-activated. Good idea, doesn't work. My cat doesn't meow, so the sensor would not detect my cat. Next to that, the sensor would probably react to everything else so it would get activated by even the most minimalistic sound.

Step 2: The Parts

This project was build with the following parts:

  1. Arduino Uno
  2. Servo's (2x Tower Pro Micro Servo 9g)
  3. UltraSone-sensor (HC-SR04)
  4. 2x battery holders for 4 AA battery's
  5. A breadboard
  6. A laser element (KY-008)
  7. An 3D-printed piece to connect the two servo's
  8. Jumpwires (Male to Male and Male to Female)
  9. Powerbank to power the Arduino
  10. A box

TIP: To make sure the wires aren't getting out of their destinated position you can use a glue gun to connect the pieces. It's quite easy to remove the glue when it's not needed anymore but it hold's everything together when the toy is operating.

The 3D printed part is designed in Autodesk Inventor 2017. In the figure above is the technical drawing to reproduce the servoconnector. Once its printed the servo's are connected with a glue gun to this connector.

Step 3: The Circuit

In the figure above you can see the batterypacks ( NOTE: The picture shows two AA battery's per servo, it has to be four per servo!) connected with the arduino and the breadboard. Unfortunatly, Fritzing (the program I used to draw the circuit) didn't reckonize the laser and the UltraSone-sensor so I couldn't draw it there. Also, me drawing it on paper would only make things messier so down here I explained how everything is connected.

Servo 1:

  • Input pin Arduino: 9 (PWM)
  • +wire: Battery pack
  • -wire: Common ground on breadboard

Servo 2:
Input pin Arduino: 10 (PWM)

  • +wire: Battery pack
  • -wire: Common ground on breadboard
  • The 'Common ground' on the breadboard is connected to the Arduino by a wire leading to the GND.

Unfortunatly the program Fritzing doesn't reconize the UltraSone-sensor and the laser so it's connected like this:

Laser:

  • Input pin arduino: 5 (PWM)
  • +wire: 5V pin output Arduino
  • -wire: GND on arduino

UltraSone-sensor:

  • +wire: 5V pin output Arduino
  • -wire: GND on arduino
  • Echopin Arduino: 11 (PWM)
  • Triggerpin Arduino: 6 (PWM)

Step 4: Arduino Code

If everything is installed correctly the toy will work as showed in the video!
#include 

Servo servoonder;
Servo servoboven;  
int vertraging = 50;
int updelay = 20;
int x = 0;
int laserup = 115;
int down = 0;

int laser = 5;

int echoPin = 11;
int trigPin = 6; 
long duration;
long distance; 


void setup() 
{
servoonder.attach(3);
servoboven.attach(9);
Serial.begin(9600);
pinMode(echoPin, INPUT);
pinMode(trigPin, OUTPUT);
pinMode(laser,OUTPUT);
}

void loop() 
{
US();
if(distance<=15)
  {
  digitalWrite(laser,HIGH);
  
  for (x=0;x<5;x=x+1)
  {
    Serial.print("x = "); Serial.println(x);
    for (down=0; down<90; down+=3)
      {
      servoonder.write(down);
      laserverticaal();
      }
    for (down=90; down>0; down-=3)
      {
      servoonder.write(down);
      laserverticaal();
      }
  }
  digitalWrite(laser,LOW);
  }
}

void laserverticaal()
{
    for (laserup=115; laserup<=140; laserup+=1)
    {
    servoboven.write(laserup);
    delay(updelay);
    }
}

void US()
{
digitalWrite(trigPin, LOW); 
delayMicroseconds(2); 
digitalWrite(trigPin, HIGH);
delayMicroseconds(10); 
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration/58.2;
Serial.print("Afstand = "); Serial.println(distance);
delay(10); 
}

}</p>

Step 5: The Assembly

Once everything is installed and placed inside the project is ready for use. I used a glue gun to connect the wires from the Arduino with the components, and to set the horizontal moving servo to the box. As said before, the reason to use a simple box from the store is because it is easy to edit. In this final assembly I cut two holes in it for the UltraSone sensor and for the power cable from the Arduino. Above are some pictures of the final result. Oh by the way, my cat absolutely loves it!

If you are trying to make this or even already made it, please let me know! If there are any questions, just ask me and I'll try to answer as fast as possible. Feedback is very much appreciated!

First Time Author Contest 2018

Participated in the
First Time Author Contest 2018

Arduino Contest 2017

Participated in the
Arduino Contest 2017