Raspberry Pi Object Detection Cat Toy

This object detection toy will keep your cat's head spinning for hours!

Who ever thought your cat would be interested in a raspberry pie pi? This Pi project can be activated simply by a moving object, so it is easy to trigger and pet-friendly. Set it on the floor and watch their heads spin!




Olive gets a little lonely sometimes around the house, so I wanted to create something that he could use while I am gone. Thanks to this handy object-detection design, Olive is able to turn his toy on and off whenever he pleases (if he ever pleases).

When something passes over the detector, the toy turns on and remains on until a second pass is detected. The elevated platform encourages Olive to pass by the photoresistor when he is walking toward or away from the toy. If you turn this into a dog toy, it might find a bit more use; Olive didn't seem to care.


The Raspberry Pi is an embedded computer that we can program with Python. Thanks to the original AAC project (which has more details), I was able to do this in no time! Let's first talk about the circuitry, and then we'll move on to programming.

The Object Detection Cat Toy involves two separate circuits: a photoresistor light-detection circuit (somewhat similar to our Laser Tripwire project) and a relay-driver circuit (also used in our Crop Duster Buster project). As you know, the resistance of a photoresistor varies according to the intensity of the light illuminating the device.


We convert this to a changing voltage by creating a resistive voltage divider. You may think that we plugged the LDR directly into the GPIO pin, but that wouldn't work. Within the code, we enable the pin's internal pull-up resistor so that the input to the GPIO is actually the output of a resistive voltage divider consisting of the photoresistor and the internal pull-up resistor.

We're using a digital pin here, so the analog voltage from the divider is simply interpreted as a logic high or logic low. As light intensity decreases, resistance (and hence the divider voltage) increases, and at some point the Pi will detect a logic high on GPIO4. Then, the Pi sends a logic high to the base of the transistor in the relay circuit.

Read More:  Raspberry Pi Object Detection Cat Toy

About The Author

Ibrar Ayyub

I am an experienced technical writer with a Master's degree in computer science from BZU Multan University. I have written for various industries, mainly home automation, and engineering. I have a clear and simple writing style and am skilled in using infographics and diagrams. I am a great researcher and is able to present information in a well-organized and logical manner.

Follow Us:
Scroll to Top