A few weeks after we got our puppy, we taught her how to turn on a light.

Turns out Kaira will do just about anything if you can clearly communicate your desires and have a treat in your hand. There’s an Ikea lamp in our bedroom that’s activated by stepping on a floor switch. We started her training by placing her paw on the switch, saying “Light,” and giving her a treat. Once she got that, we’d press on her paw and withhold the treat until she heard a click. Eventually, we could say “Light” from across the room and Kaira would run over and do the job:

Shortly afterwards I started thinking, “I’ve got a dog that can press a button. What can I do with that?”

Doggy Selfies

When Twilio launched Programmable MMS, I started to wonder if we could teach Kaira to send selfies. I’m pleased to say that thanks to the Arduino Yun and a big red button, the answer is a resounding “Yes!”:

What you’re seeing in the video is a cigar box housing a massive arcade button and an Arduino Yun. The second box serves as a stand for a webcam that’s plugged into the Yun. (My local cigar shop sells empties for $2 which make for sturdy and stylish hardware enclosures).

The WiFi enabled Arduino Yun has two microprocessors: one does all the pin interaction you typically associate with an Arduino. The second runs a stripped down version of Linux called OpenWRT which can run programs in your favorite scripting language (Python comes pre-installed, but you could put Ruby or Node on there if you so please). This project has one program running on each processor. Together, they are less than 60 lines of code.

The Arduino sketch simply: