BREAKING NEWS

25 October 2015

Automatic Cat security

CatBot an autonomous laser toy for your cat. You may say, "But Joe, lazy cat owner is not the best toy laser pointer?" I do not, CatBot that need to be taken a step further.

Using two servos, an Arduino and a cheap $3 laser you can provide your cat with endless fun.






I was buying pet food and saw a $3 laser from PetCo. I thought the cat might like it. I was wrong. The cat became obsessed. Constantly grabbing the toy off of the coffee table. But she only wants to play for 1 minute then sit and stare at it. So you think, OK I guess she is bored. You put it down....

And she's back pawing at it.

For this I used the following:


  • Arduino Uno
  • Hillman Hobby Parts (found @ Lowes in the screws/nuts/bolts area)
  • 2 Servos
  • Zip Ties
  • $3 Laser cat toy.

Disassemble the Laser



The laser pops open with a screw driver. You can see it used 2x1.5v batteries. But it actually runs better at 4.5v.




Build the Servo Tilt/Pan


I used a hodgepodge of these cool mechano/erector set pieces from Hillman. They can be found in the screw/small parts drawers at Lowes.


Wire for Arduino



For the Arduino wiring, attach pins 8 & 9 to the servos.
Attach the laser to 5v, but 470 ohm resistor inline before the laser.


Arduino code


#include <Servo.h>

Servo vert; 
Servo hor;

void setup() { 
  vert.attach(8);
  hor.attach(9); 
}

void migrate(Servo &myServo, int newPos) {
  int wait=random(30,60); //randomize the wait to make it more interesting
  int pos = myServo.read(); //Read the current servo position
  if (pos < newPos) { 
    for (int i=pos; i < newPos; i++) {
      myServo.write(i);
      delay(wait); 
    }
  } else { 
    for (int i=pos; i > newPos; i--) { 
      myServo.write(i);
      delay(wait);
    }
  }
}
    
  
void randomPosition() {
  int rand=random(40,120); //The range is limited to 60 deg for better cat action
  migrate(hor, rand);
  
  rand=random(90,135); //The vertical range is limited to 45 deg also for better cat action. 
  migrate(vert, rand);
}
   
void loop() { 
  randomPosition();
  delay(2000);
}







Share this:

Post a Comment

 
Back To Top
Distributed By Blogger Templates | Designed By OddThemes