Keeping a modern cat entertained requires something more high-tech than a ball of yarn. The MagPi’s Phil King wonders if this is a purr-fect project…
WARNING! LASER EYE! Don’t look into a laser beam, and don’t point a laser beam at a somebody’s head. For more on things you SHOULDN’T do with a laser, visit magpi.cc/lasersafety.
Xander the cat is a much-loved family pet, but as his owners live in a flat, he can get a little bored staying indoors when they’re out at work. Seeking a way to keep his cat entertained, Enzo Calogero came up with an ingenious Raspberry Pi–powered project. “We noticed that he loves to chase a laser light, so we decided to create a device to make laser games for him,” explains Enzo.
The result is the Tri-Lasers for Felines device which, when the cat’s presence is detected by a PIR motion sensor, beams a laser dot around the room for Xander to chase between randomly generated points. Judging by the video on the project’s Hackster tutorial page, he seems to love it.
Pan and tilt
The laser’s main movement trajectory is handled by mounting it on a Pan-Tilt HAT, which has vertical and horizontal servo motors. “A pair of coordinates (x, y) is generated randomly,” explains Enzo. “The laser point moves from the current point to a new coordinate, following the segment that connects the two points, at a speed defined by a status variable. Once the new coordinates are reached, we loop back to point one.”
To add extra interest for Xander, its movement is randomised further by switching between three laser diodes to perform micro random movements very quickly. “Switching the active laser among the three allows extremely rapid movements of the laser dot, to create an extra variability of the light trajectories which seems more enjoyable for the cat,” says Enzo.
While the laser point is visible in daylight, it shows up better when there’s less light: “Xander prefers it when the room is completely dark.”
The device’s three laser diodes are set into a 3D-printed triangular holder that sits atop the Pan-Tilt HAT’s acrylic mount — which would normally be used to hold a Camera Module. Enzo also designed and 3D-printed a case for the PIR sensor.
In addition to handling laser movement, the Python script saves a log of Xander’s activity: “We check it now and then out for curiosity,” says Enzo. “When Xander was a kitten, he was playing with it very often. Now he is a bit older and much more prone to sleep rather than play, we switch it on when we are out in the evening to keep him busy during our prolonged absence.”
One issue that came up is that, being naturally curious animals, cats are prone to investigate any new objects. “We try to put it as high and unreachable as possible, but cats are extremely skilled,” says Enzo. “So, he was able to reach the device few times. And the best way to save the device from cat attacks is to make it as still as possible, so the cat loses interest.”
Therefore a tilt sensor was added to the device, to cause it to shut down if triggered by an inquisitive Xander, thus reducing the risk of damage.
This isn’t the only feline-focused project from Enzo, who has also built an IoT food scale to monitor when and how much Xander eats, sending the data to a Google Cloud online dashboard. He’s now working on a wheeled robot to track the cat with a camera and perform a few interactions — we wonder what Xander will make of that.
More from The MagPi
The MagPi magazine is available from newsagents in the UK, Barnes & Noble in the US, the Raspberry Pi Store here in Cambridge, and online in the Raspberry Pi Press store.
This month’s issue comes with a free stand for your Raspberry Pi 4. Yay!
A note from Alex regarding cats and lasers
Some cats don’t like lasers. They find it far too upsetting when they can’t catch what it is they’re chasing. If your cat starts to pant while chasing lasers, don’t assume it’s just exhausted. Panting can be a sign of stress in cats, and stressed is something your cat shouldn’t be. Exercise caution when playing with your cat and laser toys, and consult a vet if you’re unsure whether their behaviour is normal.
The owner of a cat who doesn’t like laser toys