Last Christmas I had an idea for a tree in our office which you could interact with but ran out of time last year so this year I decided to build it, and the BBC Radio Tree was born! The tree lived in Broadcasting House where we work; in the Radio 1 / 1Xtra production offices.
The tree has been featured in BBC Ariel news: Tweet the tree to change its colour
The tree has a Ruby script running as a daemon on a Raspberry Pi. This polls twitter for any mentions of the hashtags #red #green or #blue tweeted to [@bbcradiotree](https://twitter.com/bbcradiotree]. The script then uses a simple RGB binary bitmask to send a single byte to an Arduino Uno over the USB serial port. So, to turn the red lights on, 1 (or binary 001) is sent. To turn the red and green lights on 6 (or binary 110) is sent; and so on
The Audino Uno uses a Seeedstudio Relay Shield V2.0 and three sets of mains-powered lights which have a transformer which supplies 24v to the LED strings themselves. The relays mean that the lights can only be on or off (without pulsing the relays) but that’s ok for now.
When a tweet is received with some colour hashtags, the service will update the tree with the correct lights, then if there are more to deal with it will pause for a while before changing the lights. The service will then tweet the person back. Although sometimes the polling means that it takes a while to get a tweet, the gem will return a time to pause if Twitter throttles the polling so the service can then sleep for that amount of time.
The tree also has a home-made star which I made from an old DVD box, some gold spray-paint, glitter, some rhinestones and an old LED scrolling name-badge I had lying around. The message that scrolls across the star is the instructions how to tweet the tree. Though it’s programmed with the text to scroll I did realise it has a USB connection and some googling revealed you can send text bitmaps to the badge, so I might play around with that next.
The biggest issue to deal with has been the Twitter polling, which keeps throttling and making the service wait; usually around 400 seconds. I’m using The Twitter Ruby Gem to poll Twitter and post replies, but streaming would be a much nicer option.
It’s a bit rough and ready at the moment and I’ve also had to slow down the serial communications to the Arduino from the Raspberry Pi as it seems to drop a lot of data when using the Pi which doesn’t happen from my Mac. Next version would be good to implement Twitter streaming and ful RBG LEDs which can offer a lot more colours. I did have plans for an LED matrix which would display the person’s name who has tweeted the tree, but while I built it I only had one Arduino and had to use that for the relay shield. Version 2.0! ;)
Code on Github: github.com/betandr/bbcradiotree