Friday, July 6, 2012

Using a MicroController to Train a Cat

Most of the time Kelso is a great cat.  A few examples of his awesomeness can be seen here, here, and here.  However, he still seems to squeeze in some mischief despite a rigorous schedule that includes sleeping 18 hours a day.

For example, we spotted some paw prints on the stove vent hood.  But wait... Kelso is strictly forbidden to even think about getting on the counters so it couldn't have come from him.  Impossible.  Up goes a security camera to gather more evidence:
-----
Busted!  We need a solution and it needs to be high tech.  

A quick search of the spare parts bin at "The Lab" yields a PICAXE 28X1 custom programmable microcontroller, a piezo speaker (that is really really loud!), a Sharp InfraRed Rangefinder, and a AA battery holder.
-----
All of that stuff in the picture is useless as a solution without some simple custom programming.  Basically, we coded the PICAXE 28X1 to continually monitor the Sharp InfraRed Rangefinder to see if Kelso is in front of it.  If he is, blast five LOUD chirps through the piezo speaker then rearm and wait.  The code was easy and straightforward; less that 20 lines.  The only thing special we did was turn off the PICAXE 28X1 brown out detection (disablebod) and slow the internal clock down from 4MHz to 31KHz in an effort to extend battery life.  Here is a pic of the finished rig that will keep Kelso from ever misbehaving again. ;)

-----
And here is demo of the rig in action:


-----
Does it work?  Hell yes it does!!!
Thanks for checking out the build.
-----
Link back: Hack A Day
Link back: Hatched Gadgets
-----