I’ve been looking for an automated cat feeder, and haven’t been very happy with the options. I need it to dispense a very small amount, and only when the cat is present, to avoid it piling up and letting her eat too much at once. (Bad things happen then.) The closest thing I found was the Wireless Whiskers feeder, but I just wasn’t inspired to spend $150 and then fuss with programming it on a tiny screen. And then @bitsandhops posted this:

Following the link from the Robokitty source code to the servo she used, I discovered Adafruit and promptly sent them all my money.

I knew I wanted to use Elixir (of course!) so I went with a Raspberry Pi starter kit, and then discovered that the RPi doesn’t really do servos, so I added the Servo HAT. And a proximity sensor, etc., etc. Once it works I’ll do a post with all the details and a parts list.


Not having done anything with hardware since college (that course where I spent hours and hours in a windowless basement sticking Motorola chips into breadboards…) I started with the “Hello World” of the embedded space: blinking an LED.


(Actually I first wired it directly to power, which is what you see above. Later I moved that red wire over to GPIO pin #4 as described here.)

After reading a bunch of blog posts and with @fhunleth’s excellent elixir_ale library, (and his patience in answering LOTS of questions,) it turned out to be as simple as:

defmodule BlinkyAle do

  def start do
    {ok,pid} = Gpio.start_link(4,:output)

  def blink_forever(pid) do
    :timer.sleep 1000
    :timer.sleep 1000


The elixir_ale library even exports the pin you want to use to make it available, which is described in this blog post. Under the covers this uses sysfs which entails writing a value to a file, after which Linux does the right thing.


Having conquered blinking an LED, I turned to the servo. This meant soldering the header and some pins onto the HAT. I watched:


I spent a frustrating afternoon trying to reverse engineer the Python example code that Adafruit provided, and (after reading more blogs and asking more questions) I figured out that I was supposed to have a Datasheet to work from.

Some searching and one Support Forum post later, I confirmed that the PCA9685 Datasheet is what I needed, and things got MUCH easier.

With it all plugged in and working:

ElixirSpinny from Wendy Smoak on Vimeo.

The code is here: Spinny.


For our last trick, it’s back to the LED, this time with the VCNL4010 proximity sensor wired up.

ElixirProximityBlinky from Wendy Smoak on Vimeo.

Here is the code that makes it work.

This was a matter of connecting the right pins from the sensor to the RPi, as shown in in the Adafruit example project and the Datasheet. @fhunleth explained that the SDA and SCL pins are what put something “on the i2c bus” so it can be addressed and written to / read from.

Next Up

Next up I’ll need to get both the servo and the proximity sensor attached at the same time, so that instead of turning on a light when something is near, I can spin the servo. As soon as the next box from Adafruit arrives, I’ll have the additional parts I need to make that happen.