Category:PCB Assembly Raspberry Pi

Group Administrators: 1 | Group Member: 47 | Group Threads: 44

The Raspberry Pi is a series of small single-board computers developed in the United Kingdom by the Raspberry Pi Foundation to promote the teaching of basic computer science in schools and in developing countries.

Thread Reply
Raspberry Pi Object Detection Cat Toy Reply 2017-01-23 17:22:04
1K+ views
1 comments
425 likes

Teo Anca

Leave A Message

Follow

This object detection toy will keep your cat's head spinning for hours!
Who ever thought your cat would be interested in a raspberrypie 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!
BOM:
  • Raspberry Pi (model A+, B, B+, or the Pi 2) and necessary components
  • Photoresistor (AKA light-dependent resistor/LDR)
  • 220 Ω resistor
  • 2N2222 NPN transistor
  • 1N4001 diode
  • 5V relay
  • DC motor
  • Extra batteries or a separate power supply (for the motor)
  • Feathery thing
Why?
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 entire Cat Toy, built on elevated pegboard.
How?
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.
A graph showing the nonlinear, inverse relationship between light intensity and the resistance of a photoresistor.
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.
Full Cat Toy circuit diagram, made using Fritzing. Click to enlarge.
To get up and running, you must first install the free open-source operating system, called Raspbian, onto your Pi's SD card. With your Pi properly hooked up to a monitor, mouse, and keyboard, open the "Terminal" application. This is where the Python code will be written, in three easy steps:
  1. Download the Python code by clicking on the orange button (scroll down a bit) and then save it to the /Pi directory as-is.
  2. Enable the Pi's Python GPIO library by copying and pasting the following code. Allow the command to run and then wait for the next prompt.
sudo apt-get install python-dev python-rpi.gpio
3. Then, tell the terminal to run the Object Detection program using the following command:
sudo python object_detection.py
Object Detection Cat Toy Code
You've done it! If you have any issues, remember to refer to the original project for further details. You can also check out the Adafruit tutorial on using the Pi's GPIO!
Take this and run with it! The object detection circuit can be adapted for use in a variety of applications. My first instinct is to always think of my cat, but maybe you have a clever plan for touchless power control! Wouldn't it be nice if your house lights turned on when the Pi detected you walking through the door? Combine this with other Pi home-automation projects and have your first Smart House!
Remember to always check out our previous projects (the earlier ones just might help you to understand the later ones) and let us know what you think!
Other MIT-i Innovations:
  • The Cat-Apult! (an Arduino-controlled servo for makers)
  • The Launchpad-Based Laser Tripwire Alarm! (a Launchpad security system)
  • The Arduino UNIVERSAL Remote Control! (an IR receiver for your entire house)
  • The Crop Duster Buster! (a clap-controlled odor-management system)
  • The Traffic Light Controller! (an Arduino delay statement lesson)
  • The Dancing Ghostbusters Toaster! (a lesson on solenoids and inductive loads)
425 likes
Statement: This post is only the personal view of the author and does not represent the opinions of ALLPCB.com.

adam.yh.lee

Leave A Message

Follow

Please keep us up to date like this.
ThreadReply