Austin Robertson

musings and thoughts from yours truly

Hello World! I have migrated my blog to Octopress and deployed to GitHub Pages. Installation and deployment was a snap. Looking forward to see how Octopress and Jekyll evolve since Tom Preston-Werner and the GitHub team will be working on Jekyll more this year.

A tweeting miniature Christmas Tree controlled by Twitter. Powered by the CheerLights project. Tweet #cheerlights and a color: red, blue, green, white, magenta, cyan, yellow, purple, orange, and warmwhite.

How it Works

(in plain English)

@OhChristmasTwee is a cheap 32” miniature Christmas tree with fiber optic lights from Walmart. But this is no ordinary tree. @OhChristmasTwee is plugged into the CheerLights project. The CheerLights project is a worldwide network of Christmas lights that sync their colors via the Twitter hashtag #cheerlights. That’s right folks, you can control the color of my Christmas tree (along with all the other cheerlights in the world) from your Twitter account.

When anyone includes the hashtag #cheerlights and one or more color words in their tweet, all Cheer Lights across the world will change to the color you’ve command. For example:

@austinrobertson: Let’s paint the world blue! #cheerlights

Now all cheerlights, including @OhChristmasTwee, will be blue! @OhChristmasTwee will even give you a @mention shoutout containing a clever Christmas phrase and the colors you tweeted. But wait! There’s more! (Stop reading if I’ve already blown your mind.) You can watch the colors change live below via LiveStream!

So spread some Christmas cheer, try it out, and bring a little color to the world! Or build your own. All source code is available on my GitHub

Watch Live

Update: It’s been fun, but @OhChristmasTwee will be offline until next Christmas. Until next year…

Geeky Details

Real Time Color Change

The original CheerLights project taps into the convience of the ThingsSpeak API. ThingSpeak is an open source Internet of Things application and API to store and retrieve data from things using HTTP over the Internet or via a Local Area Network. With ThingSpeak, you can create sensor logging applications, location tracking applications, and a social network of things with status updates.

This is a powerful tool if you have a simple microcontroller, like a network enabled Arduino. You can code simple polling HTTP requests to send or retrieve data. But the problem is this: While data-collection on the ThingSpeak backend is realtime, data-retrieval is polled at a set interval. Depending on your polling interval, this means your data-retrieved may be seconds or even minutes old. And decreasing your polling interval will decrease the age of your data but increase the requests load.

If you take a look at my code, I went about things a bit differently. I’ll be the first to admit that my code is anything but “good code”. But from a design point of view, it’s better. My (Python) code taps into Twitter’s realtime Streaming API. It does not use HTTP GET requests to retrive data. Instead of asking, “Hey Twitter! Is there any new data?” every 5 seconds, you say, “Hey Twitter! Give me new data when it’s available.”. For synchronisation applications like #cheerlights, this is a better solution. Lights would only be out of sync by less than 100 milliseconds probably. (Depending on your network latency.)

Of course, there are drawbacks to this solution. This solution requires more hardware. You need an Ardunino interfaced with a PC, instead of only an Arduino + Ethernet / ioBridge. This is because (to my knowledge) there is no Arduino library to interface with the Twitter Streaming API. However, that’s not to say it is not possible. But I am no AVR-LibC expert.

In the end, it worked out better for me because I did not have an Ethernet Arduino or ioBridge on hand. Consider this the poor man’s solution.


Since it’s the season to be jolly, I figured I would add some @replies to anyone who changes colors. @OhChristmasTwee will respond with a clever Christmas tweet with the color(s) integrated into the text. It also includes a URL if you plan to live stream your tree. This makes things a little more fun.


I don’t have any of those fancy GE Color Effects lights, so I had to make use with what I had. As a substitue, I am using a combination of 3 RGB LEDs. These LEDs feed light to the base of the tree where all of the fiber optic ends come together. The effect is ok, but not as pretty as the GE lights.

I also ran into a limitation of the Arduino. The Arduino only has 6 PWM pins, which means I can only tap into PWM on two RGB leds (2 LEDs x 3 colors / LED). Because the fiber optics need a bright source, you really need 3 LEDs to get good color. I compromised by using 3 LEDs for colors red, green, blue, black, white, yellow, cyan and magenta. You don’t need any pulse width modulation to achieve these colors since it is just a combination of on and off. For orange, purple and warmwhite, I use only the 2 PWM LEDs. I had to kinda guess with the color codes to match the GE Color Lights, but thats a minor detail.

Not all RGB LEDs are created equal. Some share a cathode and some share an anode. So you may need to change the pin HIGH / LOW state in my code.

More Hardware

I already mentioned this, but my solution requires a PC as a substitute for the Arduino Ethernet or ioBridge. While this doesn’t feature the portability of something running only on an Arduino, it’s a little more fun to make!

Build your own



I followed this Instructables guide for interfacing an Arduino with RGB LEDs



This is the code to load onto your Arduino. It’s pretty simple code. loop() waits to receive serial commands like “red” or “blue” then changes the color accordingly. You’ll have to modify which pins you are using. Also, not all RGB LEDs are created equal. Some share a cathode and some share an anode. So you may need to change the pin HIGH / LOW state in my code.

If you are only using 1 or 2 RGB LEDs, you might have to do some further modifications to my code. Then, you can essentially send all colors to the LED12() function.

This is the Python script that runs on your computer. The script monitors the Twitter stream for #cheerlights hashtags, tweets for @OhChristmasTwee, and sends serial commands to the Arduino. You will need to modify the following to your liking:

Get your Cheer On

After connecting your flashed Arduino to your pc and configuring the script variables, execute ./ (or python from the command line to fire up the script. If all goes well, you should see something like this:

*** Initializing serial...
*** Serial connected!
*** Serial testing...
*** Sending commands to serial...
*** Serial: red
*** Serial: green
*** Serial: blue
*** Getting last color from ThingSpeak...
*** Sending commands to serial...
*** Serial: green
*** Authenticating Twitter bot...
*** Authorized!
*** Connecting to Twitter stream...
*** Connected!
*** Waiting for tweets matching hashtags...
2011-12-10 12:50:10.066194
New tweet from: benbarthdotcom

@cheerlights The Christmas tree is a beautiful green!
*** New color command(s) found!
*** Sending commands to serial...
*** Serial: green
*** Tweeting...

OhChristmasTwee tweeeted:
@benbarthdotcom reads, "Twas the night before Christmas. Lights green, shining a bright!