A Very Chartbeat Christmas

11/12/2014 18:00 GMT | Updated 10/02/2015 10:59 GMT

TL;DR I made some Christmas tree lights that change colour and pattern based on how many people are reading HuffPost

This time last year I got back to London from a trip to the HuffPost mothership in New York to find the office transformed. As part of a desk decorating competition, each group on the floor had gone to extraordinary lengths to trick out their work space with lights, tinsel and, in the case of my team, idols of Miley Cyrus (including a Miley-themed Barbie doll riding a ''wrecking bauble'). We won the award for 'Most Tacky', deservedly.

I couldn't match that - what could? - but I did want to contribute to decking the halls this year, and I also wanted a challenge. The accumulation of a year's guilt at the dust gathering on my Arduino Uno, and the inspiration of having seen this excellent example of how to rig up lights linked to Chartbeat (our main realtime traffic tracking tool) got me thinking about how I could put together some stats-powered Christmas tree lights for the team's contribution.


My first version was a few multicoloured LEDs on a breadboard, lighting up red or green based on how many people were reading huffingtonpost.co.uk. I used Processing to pull down figures from the Chartbeat API, and then passed a value to the Arduino (just like in the example), for it to interpret and output to the lights. In my enthusiasm, I dashed to a Makerfaire in Elephant and Castle, breathlessly bought some cheap neopixel clones and a soldering iron, and spent the next day accumulating small burns to the hands and the tangy taste of evaporated solder in my mouth. The pixels died on the table, so it was back to the drawing board.


For my second attempt, I was lucky to have a smart friend who lent me some more user-friendly lights, with individually addressable LEDs that light up in seemingly any colour you like. From there, it was plain sailing. I added some more states for different colours, and set up in the office on Monday. At first the lights were linked to how many people were on the site in total; that changed through the day too gradually for it to be clear the lights were doing anything, so on Tuesday I came back with the code linked to the change in concurrent visitors over the past minute - now if we've added lots or a few concurrent visitors, or lost a few or lots, the lights do something different. Here's the Rainbow pattern that fires off if things are going really well:

Two things struck me while I was putting this together.

First, the fact that just by using relatively cheap components and free online tutorials someone with no coding background can make something like this work is a modern marvel. Until fairly recently, you would have needed experience in electronics and computer science to do something simple like make some lights change colour based on something like this. (Of course, saying that, the majority of the technological complexity is on Chartbeat's side (powering an API is a lot more difficult than communicating with one)).

Second, the reaction from curious colleagues is even more evidence of the fact that when you're using data in a publishing company you have no choice but to be creative. It isn't enough to present spreadsheets, dashboards etc - you have to understand that smart, creative people like journalists and product managers need to be communicated with creatively. Even if that means the odd burn from a soldering iron along the way.

Thanks to John Keefe for publishing his example code, which I based this on.