Sam Brenner

TwitShit

My first project for Physical Computing was to find a creative way to turn an LED on and off using Arduino. A while ago, I said that the only way I’ll use Twitter (which I think is beyond pointless) was if I could hook it up to our cat’s litterbox and have it “Tweet” every time the cat takes a poop. An LED would light up to signal “the litterbox is occupied” or start flashing to signal “warning: it may smell awful.” And that’s exactly what I did!

I had first planned to install an ultrasonic sound emitter inside the litterbox to detect if there was something inside. When I went to Jason to look through his box-o-sensors, however, I found the flex sensor which was not only much easier to use than the ultrasonic emitter, but it would be much easier to code for as well. The flex sensor outputs a number which tells me if it is bending one way or another.

Once I had wired up the board, I took to writing the code. The Arduino code checks three times a second to get the value of the sensor. If it is bending into the litterbox, it signals the LED to turn on. If it is bending out of the litterbox, it tells the LED to flash for a few minutes. The Processing code is responsible for posting the Twitter updates, which works like this: the Arduino board is able to broadcast information via the USB port back up to the computer, which Processing listens for — this is called a serial event. Depending on what the event parameters are, I can tell which direction the sensor is flexed in and post the appropriate tweet using a nifty library called JTwitter. Here’s a screenshot of the programs running on my laptop (technically, Arduino doesn’t have to be open for it to work, but it looks cool with them both there):

And here is a picture of the installed "device":

If you’re interested, you can follow our beloved cat Reptar on Twitter here.

Next Post: Beginning node.js and socket.io