Step 12: Building the Box

Step 13: Enjoy!

Some possible extensions include: Making it multilingual and not just English speaking places. Perhaps just associating with a keyword, for ...

How's the world feeling right now? This box tells you.

Powered by: an Arduino, a WiFly wireless module, an RGB LED, Twitter.com and a 9v battery.

I’m a news junkie. I want to know everything that is going on in the world as soon as it happens. I want to wake up and know immediately if something big has happened overnight.

However, I’m an extraordinarily busy man; I don’t have time to read news feeds; reading that headline that I already knew about or don’t care about is time that I’m never getting back!

No. What I need is some way to be constantly in touch with the world's events as they unfold, alerted when something big happens, and to be made aware of it all faster than awareness itself!

...A way to get a glimpse of the collective human consciousness as an extension of my own. Something that I don't have to continually check or poll, but instead, like a part of my body, it will tell me when it's feeling pain or generally in need of my attention ...leaving me time to get on with other things.

And so, I present: The World Mood in a Box!

The Arduino connects directly to any wireless network via the WiFly module, continually searches Twitter for tweets with emotional content, collates the tweets for each emotion, does some math, and then fades the color of the LED to reflect the current World Mood; Red for Anger, Yellow for Happy, Pink for Love, White for Fear, Green for Envy, Orange for Surprise, and Blue for Sadness.

If an unexpectedly high number of tweets of a particular emotion are found, then the LED will flash to alert us to the possibility of a world event that has caused this unusually strong emotional reaction.

For example, a world disaster and it may flash Blue or Red (sadness or anger), if the strong favourite loses a big football game it may fade to Orange (surprise), …and If it flashes White, the collective human mind is feeling extreme fear, and it's probably best to go hide in a cupboard and sit it out, waiting for sunnier skies and a return to Yellow or Pink. ...OK, I'm not that busy.

The world has changed a bit since this program was first posted. I finally have my mood light working, but it wasn't always easy.

First, make sure you buy an Arduino Duemilanove. Yes, there are newer devices out there. No, you do not want them. They are all supposed to use the same code, but this code is sensitive to the timing on the Duemilanove. Use another board and you'll be fighting issues all the way. After over a year of this, I just switched and I'm glad I did.

Second, the Twitter world moves much faster than it did. 30 tweets of the original terms go by in less than a second. Since everything is computed in tweets per minute, this obviously won't do. Everything registers off the scale.

You'll have to substitute this code in TwitterParser.cpp to compensate.

I also had to modify my LED.cpp file to make sure colors showed up properly. In particular, I had to adjust the array values in the beginning to accurately show colors with my LED -- apparently my red isn't as bright as the blue and green and so full value on all three skews the colors. I added the following text to the WorldMood.cpe to make it easy to test light colors -- right after the device starts up, it triggers the light to the values specified. Value range goes from 0 to 255.

Hey, the new API requires OATH and this project no longer works. It's a little beyond my ability to fix it, but would you like to work with me to provide updated code? This seems to be a fairly popular project and it's really cool when it works.

Is there anyone out there who has an idea of making code for aduinos? I'm having a hard time doing my project. I have no idea of what code to use. My project is about a gh-718c mini PIR motion sensor detecting my arm or hand. If the motion sensor detects that my hand is low, the light or LED will dim, and if it detects my hand on a high position, the LED will bright up. Please please. Help please. Thanks for the reply!

It is a very nice project however, you constantly search for news, does it consume a lot of battery?

Can you actually make it passively receive the data in a periodical manner? or wait for a device or app to send a 'mood' to it whenever this device receives a twitt? I know it is always possible, but what could be the implementation please? do you have any idea or example?

As I would like to make one that ideally be waiting and be triggered so to consume the minimum power

I am not even sure where to start with this comment! Bottom line, I got this running on newer hardware with a newer IDE.

Long story short: I started working on this using the 1.01 Arduino IDE, an Arduino Uno and an LED "ball" which I found referenced here: http://hackaday.com/2012/09/08/hacking-a-floating-rgb-led-decorative-ball/

I liked the look of that ball, and thought to myself "what can I do with it that is cool". I bought one, and then decided to see where I could take this instructable.

Like many of you, I ran into all sorts of errors when trying to load up the sketch and libraries to make it work.

After hacking away at it for about 8 hours over the last week, I've gotten it compiling and running on the new version of Arduino, with an Uno and not the Duemilanove. Once I get things a bit cleaner, and I document what changes I actually made,

I will post the full code somewhere and add it to this comment thread.

The quick overview:

1) Wired up my LED. I am using the LED array that came inside the ball. I also wired up a Sparkfun RGB LED Breakout to see if it would work across both. (https://www.sparkfun.com/products/10111). It does. I had to make the code change referenced in the comments and on this blog to make the colors match best with the Sparkfun LED kit. (http://www.stephenhobley.com/blog/2010/06/11/arduino-world-mood-light-using-twitter-and-wishield/)

2) In each of the libraries that were included, I had to update the code to replace: #include "WProgram.h" with #include

3) The timing and error handling are still pretty screwed up, and not where they should be. I am going to work on that next. The code will execute, and throw some errors, but in true arduino fashion, if you let it run, it will power through things and get to the next step.

4) Pay attention to the comments in "step 6", download the code: I HAD to do this. If you have a newer board then you may need to change this struct SPI_UART_cfg SPI_Uart_config = {0x50,0x00,0x03,0x10}; to this: struct SPI_UART_cfg SPI_Uart_config = {0x60,0x00,0x03,0x10};

5) Once I did those things, I got it to compile and pushed to the Arduino.

It would go out and attempt to make a request to twitter, but I'd get a 404 from twitter. This caused me to scratch my head for a day, contemplate rewriting the entire WIFLY library and then it hit me...

The http request had something wrong with it. In the worldmood sketch, you must look at the lines where you define the search request and make a small change, appending HTTP 1.0 to the end of each.

This looks like a fantastic idea. I'll probably adapt the base and use wood, and maybe allow for USB power instead of the 9V battery as well. Also, perhaps an on-off switch on the back may be something I'll do.

How long are you experiencing the 9V battery last?

Thanks for this, it's going to get me working with acrylic, something I haven't done yet.