Skip to main content

Trying to Determine Twitter's Mood

One of the projects that I'd seen that spurred me into buying an Arduino last year was an Instructable for a so-called "Twitter Mood Light." As a quickly found out- and as is pointed out in the instruction's comments- the code found there no longer works as-is. That's mostly because Twitter has changed its API formatting, and partly because using OAuth authentication is now a requirement.

Until my Arduino-compatible WiFi radio arrives, however, most of the code written for the Arduino is more or less useless to me anyway, as I have to physically tether through my computer in order to access the internet. So why not just build upon my last project and build a health bar symbolizing Twitter's mood in live time? I set out to write a new Java interface to do just that, leaving my existing Arduino program untouched.

The result is a program that queries Twitter for the most recent tweets containing the hashtags #happy and #sad. Based upon the ratio of them, a not-very-descriptive "happy value" is derived, with 30 being entirely happy tweets observed and 0 being the exact opposite. It's an oversimplification of what hashtags actually mean, but for the time being it at least does manage to cause a seemingly random pattern of lights to illuminate on the breadboard connected to the Arduino.

I'm planning on working things to derive a more accurate scale of happiness, but for now I'm sharing the code as-is for your enjoyment (and suggestions). You can find it here: