Introduction: The Laser Cat Toy. "The AutoMazer"

Here is a video of the working product above:

Step 1: The Idea

Picture of The Idea

Why spend useless money on multiple different cat toys when there is one screaming your name. The "AutoMazer" is an automated and randomized laser pointer that scans the room with its high power laser pointer. It is perfect for owners that are busy at work but also want to make their cats happy while they are away from home. Here are the steps that us here at Cathletes inc. took to create the perfect cat toy.

Step 2: Testing Stage

Picture of Testing Stage

Our second stage of this project was to check if all of our hardware was operating.

Materials used:

  • 1 UNO Arduino board
  • 1 breadboard
  • 2 servos
  • 1 laser pointer
  • 1 pan and tilt housing system
  • 1 ultrasonic sensor
  • 1 buttoncardboard
  • multiple connecting wires

The bread boards main use was to connect all of the components to the power and ground rails. The servos were connected to the pan and tilt housing system, and on top of that, the laser is connected to the pan and tilt housing unit as well. Lastly the ultrasonic sensor was alone. All together, these components create the perfect cat toy.

Step 3: The Servo's

Picture of The Servo's

The main method behind all of this madness is the two servos at work. They are connected to a pan and tilt housing system that allows the two servos to cover a whole plane of area (left to right 180 degrees, up to down 180 degrees). From there we ran some basic code to make sure that they both worked. Then finally, we implemented code that made the two servos cover a specific area, all the while being randomized.

Code:

randmov = random(180); //states the amount of degrees that the servo will move within randomly

randmov = random(0,180); // states the max and min that the servo can randomly move within

randmov2 = random(180);

randmov2 = random(0,180);

Step 4: The Ultrasonic Sensor

Picture of The Ultrasonic Sensor

The next step in this project is to implement the ultrasonic sensor. It allows the AutoMazer to turn on when the cat is near, and turn off when the cat has left.

Ultrasonic sensor code:

const int trigPin = 12;
const int echoPin = 11;

long duration; int distance;

pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT); Serial.begin(9600);

if (distance < 40)
{

if (digitalRead(btnPin) ==HIGH ) { for (int x = 0; x < 10; x++) {

servo2.write(randmov);

servo1.write(randmov2); delay (75);

} }

Step 5: The Laser

Picture of The Laser

Like any other light source in Arduino, this is fairly basic to understand and control. You can turn the laser on and off with commands such as digitalWrite, etc...

Step 6: The Circuit

Picture of The Circuit

The circuit was a basic part of this project. The biggest significance of the breadboard is just connecting components such as the laser and the ultrasonic sensor to the power rails.

Step 7: Creating the Box

The box is made out of cardboard and it is shaped into the form of a rectangular prism. After the main shape was made, we cut a rectangular hole in the top of the box in order for the servos to come through, along with the pan and tilt housing unit. When the pan and tilt housing unit was securely glued on, the Arduino and breadboard was placed inside carefully and enclosed with two cardboard squares. Two additional holes were also made for the ultrasonic sensor to come through.

Step 8: Plug in the Arduino

Picture of Plug in the Arduino

This is the final step. Along with a complete circuit, all that is left is code. Once the Arduino is plugged in, the whole project will work! Enjoy!

CODE:

#include
Servo servo1;

Servo servo2;

int xpos;

int ypos;

int randmov = 0;

int randmov2 = 0;

int servo1_pin = 10;

int servo2_pin = 9;

int initial_position = 90;

int initial_position1 = 90;

const int btnPin = 13;

int buttonState = 0;

const int trigPin = 12;

const int echoPin = 11;

long duration;

int distance;

void setup() { // put your setup code here, to run once:

servo1.attach (servo1_pin ) ;

servo2.attach (servo2_pin ) ;

servo1.write (initial_position);

servo2.write (initial_position1);

pinMode (btnPin, INPUT);

Serial.begin(180);

randomSeed(analogRead(0));

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

Serial.begin(9600);

}

void loop() { // put your main code here, to run repeatedly:

buttonState = digitalRead(btnPin);

Serial.println(buttonState);

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance= duration*0.034/2;

Serial.print("Distance: "); Serial.println(distance);

randmov = random(180);

randmov = random(0,180);

randmov2 = random(180);

randmov2 = random(0,180);

Serial.println(randmov);

if (distance < 40)

{

if (digitalRead(btnPin) ==HIGH )

{

for (int x = 0; x < 10; x++)

{

servo2.write(randmov);

servo1.write(randmov2); delay (75);

} }

/*servo2.write(180); delay (1000);

servo1.write(180); delay (1000);

servo2.write(0); delay (1000);

servo1.write(0); delay (1000);*/ }

}

Comments

Swansong (author)2017-11-07

That's a fun idea :) You could wrap those wires to protect them from the kitty chewing on them too.

About This Instructable

604views

6favorites

License:

More by EvanR39:The laser cat toy. "The AutoMazer"
Add instructable to: