Now build it out with an evocative vision. Improvise progress by tinkering: with lots of trial and lots of error. The not knowing is the best bit: the mysteries the surprises, and from time to time the windfalls!

Raspberry Pi + Makey Makey = Cats that Tweet

The Lofty Aim

The Plan

Set up sensors connected to a computer, then program the computer to send tweets when the sensors trigger.

I hatched a cunning plan.

The diagram to the left is missing one thing only: a cooperative cat...

...but how hard can that be?

The Hardware - #1 a "Makey Makey" - $50

A "Makey Makey" is a USB device that the computer thinks is a keyboard, but it actually tells the computer a key has been pressed when you put two wires together.

Makey Makey

Raspberry Pi

The Hardware - #2 a "Raspberry Pi" kit - $160

A "Raspberry Pi" is a super-cheap $35 computer... I bought mine from "Aus Pi" for $160 in a kit with a USB hub, wireless card, power etc.

I already had a webcam!

The Software - #1 Rasberrian

I'm familiar with Windows, but the Raspberry Pi computer comes with "Rasberrian" pre-installed. The good news for me is I see desktop similar to Windows, with a start button, desktop icons and a taskbar.

Python

The Software - #2 Python

I need to program the computer to tweet when the cats have their water.

Python is a computer programming language. I have never used it before. The Raspberry Pi comes with "Python" already installed and good to go.

The Learning Process

I had a stack of stuff to learn to make this work. It was much easier than I expected.

I had to figure out:

how to get around my Raspberry Pi, and specifically how to operate it remotely from another computer for convenience

how to get my Python program to run automatically when the Raspberry Pi boots up

how to program in Python: #1 to wait for input from the Makey Makey, #2 to take a photo with the webcam and #3 how to send the photo as an attachment via email to Flickr.com

I already knew how to tell Flickr to accept such emails and post them to Twitter, with the email text as the tweet, and the attachment as the photo.

I learned by:

for each element I needed to learn, googling and exploring heaps of web pages and tutorial videos

copying and pasting Python code I did not understand and tinkering with it

writing little Python programs that do just one of the tasks, one at a time, before stitching them together

The learning process was glorious... on one day I spent well over 12 hours with no proper break. Flow, flow, flow!

The End Result

You must select a collection to display.

If we build, it will the cats come?

Yes!

You must select a collection to display.

The Actual Python Code

import time

import os

import pygame

from pygame.locals
import *

import smtplib

from
email.MIMEMultipart import MIMEMultipart

from email.MIMEBase
import MIMEBase

from email.MIMEText
import MIMEText

from email.Utils
import COMMASPACE, formatdate

from email import
Encoders

import sys

import subprocess

my_subject =
"Miao Miao! Hello, this is Timo or Baps telling the world