Introduction: DaPetToy - an Automated Cat-laser-pointer-toy
I guess all cat owners know the struggle: the moment you sit down and
want to enjoy your favorite TV-show, the cat thinks “I need someone to play with me”.
Would it not be awesome if you could just pull auto your smartphone and start an automagically rotating laser pointer?
I thought so and therefore build one. It consist of two motors which can move the laser pointer on two axis. One can set via a web-server the degrees which the motor is allowed to rotate.
If I caught your attention read further and build your own!
- laser pointer
- Uln2003 driver and motor
- Esp8266 D1 mini
- Barrel jack for power input
- Jump-Wire cables
Some wood (can be replaced with 3D printing)
- 1x M4×10 screw and nut
- 2x M4×20 screw, nut and washer
- 3D printer
- basic wood working tools
Step 1: Building and Assembling the Necessary Parts
First we need to print the mounts for the motors. To do this print
the files which were mentioned in the introduction.
A little bit harder will be the making of the base case. I made the case out of wood to provide more structural rigidity (and I think it looks nicer too). The base case has one large hole on the top and a small one on the side. The large hole is for the stepper motor and the small one for the power input. Make sure that the motor-hole is large enough to fit the cables of two stepper motors and also the two wires of the laser pointer (they need space to move freely as the wires will move due to the rotation).
Now it is time to assemble it. First put the laser pointer in the mount and use the M4x10 screw and nut to fix it in place.
Next up is the power jack. Put it in the small hole and fasten it with its nut.
The first motor has to be put in the 3D printed mount and secured with the two M4×20 screws, nuts and washers.
In the second last step the other motor has to be placed in the large hole of the wood case while routing all the cables through the hole too.
Finally put the motors in their holes and also stick them together. If they do not fit tightly put some hot glue on them to secure everything in place.
Double check that the cables have enough space to move while the motors are rotating.
Step 2: Connecting the Electronics
THIS IS DEPRECATED
Please follow the instructions on the GitHub page.
The motor which rotates the laser pointer needs to be connected to the pins D5, D6, D7 and D0 of the esp. The pins of the other motor need to be connected to the pins D1, D2, D3 and D4. Also do not forget to connect the 5V and GND of both motors, the ESP and the laser pointer to the barrel jack.
Step 3: Flashing the Firmware
To flash the firmware download it from my github repository. You need to rename the file “REMOVE_credentials.h” in the “src” folder to “credentials.h”. And replace “YOUR SSID” and “YOUR PWD” in this file with your wifi SSID and password.
After completing this first step you have to upload the file system to the esp and than compile and upload the software.
Because the procedure of flashing does differ from software to software you are on your own regarding this point. But here are guides for Visual Studio Code using PlatformIO:
Step 4: Using the Device
we have reached the point where we can use the device!
When the esp is powered up and you visit its IP-address you will see an interface like the image shown here. There is basically just one mode. This moves the motors randomly around. However you can limit their movement.
Firstly, one starts the movement by pressing the “ON”-button and stops it with the “OFF” button. This button also stops other movements. The “LEFT”-button moves the matching motor “left” and the “RIGHT”-button “right”.
You can limit the movement for every motor like the following:
- press “LEFT” for the motor you want to limit
- wait until the motor reaches the position you want to set and press “OFF”
- press the “MINIMUM” button of the motor, this sets the current position as the origin
- now press “RIGHT” of the same motor and wait until it reaches the second position
- press “MAXIMUM” this saves the current position as the end point
- press on and the motor will only move in the set bounds
The origin and the endpoint are the maximum values the motor can move to and thus limiting the rotation.
- When power is removed from the esp the calibration has to be redone
- watch out that the cables always have enough space to move around
- Do NOT move the motors by hand as you will damage them
Step 5: Watch Uninterrupted Your TV Show
Was it worth all the effort just to watch TV without you cat?
Can this device help bring some joy to your cat?
I hope so.
Participated in the
Pets Speed Challenge