Laser Cat Toy

by winrtop255 in Circuits > Arduino

1793 Views, 38 Favorites, 0 Comments

Laser Cat Toy

2.gif
5.gif
1.gif
3.gif
4.gif
IMG_1770.jpg
IMG_1766.jpg

In this DIY project, we will create a simple and fun laser cat toy!

This project uses two servos, a NodeMCU, and a 9V battery to control a laser that moves around in a random pattern, keeping your cat entertained for hours.

The laser is mounted onto a 3D-printed arm and housing, making the setup sturdy and visually appealing.

Supplies

IMG_1746.jpg
NodeMCU-01.jpg
51QsVlskI2L._AC_UF894,1000_QL80_.jpg

There are only a few things you will require:


  • NodeMCU - Or a similar Arduino module
  • Two 9G servos
  • 9V battery and battery clip
  • Laser toy - Make sure it has a clip or a method to secure it onto the arm (You can find lots of these online for cheap)
  • Jumper wires
  • M2*8 Screws - You will need a few of these to secure the servos and 3D-printed arms together.
  • M2 Nut - You will need two of these to secure one of the servos to the Base.
  • M4*8 Screws - You will need four of these to secure the Base Cover onto the bottom of the housing.
  • 3D Printer & Filament - You will need access to a 3D printer and some filament to print the cat toy housing.

3D Printing

IMG_1743.jpg
IMG_1744.jpg
IMG_1745.jpg
IMG_1742.jpg
Screenshot 2024-06-21 144444.png
Screenshot 2024-06-21 144457.png
Screenshot 2024-06-21 144608.png
Screenshot 2024-06-21 144506.png
Screenshot 2024-06-21 144526.png

I designed the housing in Fusion 360 and printed them using white PLA.

The design consists of four main parts.

  • Base.stl - This is where the electronic components will be stored
  • Arm Bracket.stl - This allows the Z rotation.
  • Laser Holder.stl - This holds the laser and allows the X rotation.
  • Base Cover.stl - This covers the bottom of the base and protects the electronics.


I used the following print settings:

  • Infil: 20%
  • Layer height: 0.28mm
  • Supports: Yes (Specifically: Tree Supports)


Assembly

IMG_1748.jpg
IMG_1750.jpg
IMG_1751.jpg
IMG_1752.jpg
IMG_1753.jpg
IMG_1756.jpg
IMG_1755.jpg
IMG_1754.jpg

There are only a few steps required to assemble the entire cat toy.


  • First, mount one of the servos into the Arm Bracket and secure it using M2 screws.


  • Then, using two M2 Screws and Nuts, secure the other servo to the Base by slotting it into the allocated slot. (Make sure that the gear of the servo motor is in the centre)


  • Afterwards, secure the Laser Holder to the servo arm of the Arm Bracket by using M2 Screws.


  • Do the same thing by screwing the Arm Bracket into the servo arm of the Base.


  • Finally, thread the Servo cable from the Arm Bracket through the hole in the Base.


Now you should be complete with the assembly!

If you are confused, please look at the images above for some clarification!

Wiring

Schematics.png
IMG_1758.jpg
IMG_1757.jpg

The wiring of the Cat Laser Toy is simple, you can either follow the Fritzing diagram above or read the wiring diagram below.


9V Battery - NodeMCU

  • Positive (+) - VIN
  • Negative (-) - GND


X-Axis Servo Motor - NodeMCU

  • Positive (+) - 3.3V
  • Negative (-) - GND
  • Signal - D6

Z-Axis Servo Motor - NodeMCU

  • Positive (+) - 3.3V
  • Negative (-) - GND
  • Signal - D5



Code

Screenshot 2024-06-21 160822.png
Screenshot 2024-06-21 160830.png

How it works:

The code works by controlling the two servos to move the laser in random patterns.

In the main loop, the code generates random target positions and speeds for the servos within predefined limits.

After each movement, the code introduces a random delay, before the next movement occurs.


Adjusting the Angle Limiters:

Within the code, there are limiters in place so the Servo only draws the dot within a specified range.

You can customize the range of motion for each servo by adjusting the angle limiters in the code. This allows you to control how far the laser can move horizontally and vertically. Modify the minAngleX, maxAngleX, minAngleZ, and maxAngleZ variables to suit your preferences.



Programming the NodeMCU:

  • To begin, download the attached code file below and open it using Arduino IDE.


  • Make sure that the Servo library is installed in the Arduino IDE software. You can install it via the Library Manager (Sketch > Include Library > Manage Libraries... and search for "Servo").


  • Then, connect the NodeMCU to your computer using a Micro USB cable.


  • Select the correct board and port in the Arduino IDE (Tools > Board > NodeMCU 1.0 (ESP-12E Module) and Tools > Port > COMX).


  • Click the upload button and wait for the code to be uploaded.


Downloads

Final Assembly

FRYR9YELXNMAMEY.jpg
FH7G2P4LXNMAMFK.jpg

Finally, slot the laser toy into the Laser Holder and secure it in place.


Then, using four M4*8 screws, secure the Base Cover onto the bottom of the Cat Laser Toy in order to cover up all the electronics.

Enjoy!

FSRWJY0LXNMANBA.gif
FU6EZJKLXNMANCG.gif
FB2MBKNLXNMANA5.gif
FFPH0PULXNMAN8I.gif
FNBOF0ALXNMAN75.gif
FH7G2P4LXNMAMFK.jpg
FRYR9YELXNMAMEY.jpg

Now you are done!

Place the laser cat toy in an area where your cat loves to play. Turn it on and watch as your cat chases the random movements of the laser dot!