Teddy bear that sings happy birthday and displays facebook comments

Given we still live far away from our family and many of our closest friends, I continue to focus on creating ways to help us feel a little more connected. As my daughter turned one, I decided I wanted to enable our friends and family living all over the world to share in her celebration. To that end, I decided to build a teddy bear that could be controlled online and that would also display messages left on the website.

Building off of my xmas tree hack, I had two main user flows.
a) enable users to leave a message that would be displayed in our living room and
b) enable them to light a birthday candle.

Instead of turning on lights, I wanted a birthday candle to be toggled on/off. To do so, I bought a teddy bear that had a candle LED. I would control the candle with a relay connected to an arduino.

For the display, I decided to purchase 3 SURE LED 8 x 32 panels and connect them.

I spent a lot of time trying to improve upon my last design whereby the on/off button could not support concurrent views. If user A turned light off, user B would not know. I played with different socket services such as Pusher and PubNub – both excellent services. It was amazing to see how easy it was to set them up, even on the Arduino. The only major problem for this project, and the reason I ended up not using either of them, was how large their libraries were. When loaded alone, they worked like a charm, but when I tried to include it plus the HT1632 library, I did not have enough memory to compile. Rather than trying to optimize the libraries, I decided to scrap it altogether and search for a lighter solution. I netted out on having the web app and Arduino poll a very small api.

I stumbled upon an awesome sketch created by Santiago Reig called Tuitwall that helped me get 60% of the way there. The sketch was built to get a user’s latest tweets and display them on a single Sure LED panel – the same ones that I had purchased.

Since my endpoint was different from his and I also wanted to control a relay from it, I created new code to parse and store the necessary values. I ended up leveraging the design created by Noel Vega when we worked on the Earned Media Cube together. In fact, I based the API entirely on his previous work. Thanks Noel!

I then added a Facebook comments plugin to a webpage and built an event listener that would POST to a sqlite file. As users would comment, my api would display the latest fb comment.

The arduino would make a GET request to the endpoint every 2 seconds and check to see if anything had changed. It would store the comment and display it across the LED panel.

The next bump on the road was to figure out how to extend the sketch to support multiple LED panels. To help solve that, I found another sketch for multi-panel display and was able to retrofit the code accordingly.

I then created a ustream account and placed my iphone facing the teddy bear. This way, users on the site would be able to see their actions in real time (we ended up dealing with huge latency (+20sec), which kind of ruined that aspect of the fun)

During her birthday celebration we were able to hear the teddy sing happy birthday whenever someone clicked on the button and also read the messages left via the fb comments comments widget. My daughter was freaked out by the teddy bear, but we all enjoyed viewing the messages that were being left by our friends and family.

Notes for myself:

Thoughts for next time:

1. Have teddy turn on when visitors arrive
2. Decrease latency between api and relay
3. Figure out a better live stream solution




You may also like...