Step 4: Connecting the LED

Only some pins provide 8-bit PWM (Pulse-width modulation)
This gives 256 steps of control from full off (0) to full on (255) for each of the Red, Green and Blue channels of the LED.

PWM pins on the Arduino are 3,5,6,9,10,11. (see www.arduino.cc/en/Main/ArduinoBoardDuemilanove)

I used 3, 5 and 6.
I used the pliers to bend the legs of the LED, and mounted it on the circuit board. Each resistor is then mounted next to each of the RGB legs, and the wires are twisted together. Then I added the 4 connecting wires and twisted them. Finally, I soldered all the connections. 

Note: The pictures illustrate using the same resistor for each colour channel, but I should have used the resistance levels in the data sheet:

180 Ohm for Red
100 Ohm for Green
100 Ohm for Blue

Also note, I covered the back with insulating tape to stop any shorts when putting it all into the box.
Also, from the datasheet, "the Sensor inputs SENS0-7 are extremely sensitive to over voltage. Under no conditions should these pins be driven above 1.2VDC. Placing any voltage above
this will permanently damage the radio module and render it useless."


The world has changed a bit since this program was first posted.&nbsp; I finally have my mood light working, but it wasn't always easy.<br> <br> First, make sure you buy an Arduino Duemilanove.&nbsp; Yes, there are newer devices out there.&nbsp; No, you do not want them.&nbsp; They are all supposed to use the same code, but this code is sensitive to the timing on the Duemilanove.&nbsp; Use another board and you'll be fighting issues all the way.&nbsp; After over a year of this, I just switched and I'm glad I did.&nbsp;<br> <br> Second, the Twitter world moves much faster than it did.&nbsp; 30 tweets of the original terms go by in less than a second.&nbsp; Since everything is computed in tweets per minute, this obviously won't do.&nbsp;&nbsp; Everything registers off the scale.&nbsp;<br> <br> You'll have to substitute this code in TwitterParser.cpp to compensate.&nbsp;<br> <br> <em>#ifdef DEBUG<br> &nbsp;&nbsp;&nbsp; m_printer-&gt;println(&quot;assuming tweet was from yesterday&quot;);<br> #endif // #ifdef DEBUG<br> &nbsp; }<br> <br> &nbsp; long seconds = time1 - time2;<br> &nbsp; return seconds / 60;<br> }</em><br> <br> with<br> <br> <em>#ifdef DEBUG<br> &nbsp;&nbsp;&nbsp; m_printer-&gt;println(&quot;assuming tweet was from yesterday&quot;);<br> #endif // #ifdef DEBUG<br> &nbsp; }<br> <br> &nbsp; long seconds = time1 - time2;<br> &nbsp; return seconds;<br> }</em><br> <br> I also had to modify my LED.cpp file to make sure colors showed up properly.&nbsp; 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.&nbsp;&nbsp; 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. &nbsp;Value range goes from 0 to 255.&nbsp;<br> <br> <em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //a way to quickly test colors and connections<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; analogWrite(redPin, 255);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; analogWrite(greenPin, 35);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; analogWrite(bluePin, 0);</em><br> <br> It goes immediately after this line:<br> <br> <em>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LED led(Serial, redPin, greenPin, bluePin, fadeDelay);</em><br> <em>&nbsp;</em><br> <br> I am still adjusting my search criteria and making minor adjustments, but this solves most of the &quot;out of the box&quot; issues I've seen people experience.&nbsp;
<p>Excellent update/summary interesting that the tweets per second needs to be adjusted, i wonder if it would work on other social media platforms? </p><p>thanks for putting the time in to update.</p>
Yes, Arduino, Twitter and the World's Mood have changed a lot since May 2010. I&quot;m afraid this is not an active project of mine, and I rely on great comments like this to keep this 'ible current.
<p>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. </p>
Also, as of today, the project no longer works. <br> <br>Twitter has changed its API and now the query returns errors.
<p>Is there a way i can still make it ? </p><p>would be a great help if you can sugest a way to do this ? </p>
<p>Unfortunately, no. I've not been able to get it to interface with the new API. </p>
<p>Im gonna try and program a brand new code, but if you want to try on your own here is a place to get started: https://twitter.com/search?f=tweets&amp;vertical=default&amp;q=terrified&amp;src=typd</p>
I am not even sure where to start with this comment!&nbsp; Bottom line, I got this running on newer hardware with a newer IDE.<br> <br> Long story short: I started working on this using the 1.01 Arduino IDE, an Arduino Uno and an LED &quot;ball&quot; which I found referenced here:<br> http://hackaday.com/2012/09/08/hacking-a-floating-rgb-led-decorative-ball/<br> <br> I liked the look of that ball, and thought to myself &quot;what can I do with it that is cool&quot;. I bought one, and then decided to see where I could take this instructable.<br> <br> Like many of you, I ran into all sorts of errors when trying to load up the sketch and libraries to make it work.<br> <br> 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,<br> <br> I will post the full code somewhere and add it to this comment thread.<br> <br> The quick overview:<br> <br> 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/)<br> <br> 2) In each of the libraries that were included, I had to update the code to replace: #include &quot;WProgram.h&quot; with #include<br> <br> 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.<br> <br> 4) Pay attention to the comments in &quot;step 6&quot;, 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};<br> <br> 5) Once I did those things, I got it to compile and pushed to the Arduino.<br> <br> 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...<br> <br> 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.<br> <br> It WILL NOT WORK UNLESS YOU DO THIS.<br> <br> These lines:<br> <br> prog_char string_1[] PROGMEM = &quot;GET /search.json?q=\&quot;happiest\&quot;+OR+\&quot;so+happy\&quot;+OR+\&quot;so+excited\&quot;+OR+\&quot;i'm+happy\&quot;+OR+\&quot;woot\&quot;+OR+\&quot;w00t\&quot;&amp;rpp=30&amp;result_type=recent&quot;;<br> <br> Should become:<br> <br> prog_char string_1[] PROGMEM = &quot;GET /search.json?q=\&quot;happiest\&quot;+OR+\&quot;so+happy\&quot;+OR+\&quot;so+excited\&quot;+OR+\&quot;i'm+happy\&quot;+OR+\&quot;woot\&quot;+OR+\&quot;w00t\&quot;&amp;rpp=30&amp;result_type=recent HTTP/1.0&quot;;<br> <br> I think that is about it, but I need to go back and look at everything to ensure that there weren't other items necessary.<br> <br> The one item I haven't addressed yet is that when left as-is, the twitter search for &quot;envy&quot; still fails. I can't understand why, but I haven't taken much of a look at it yet.<br> <br> To get past this, I changed the search string from the original to this:<br> <br> prog_char string_4[] PROGMEM = &quot;GET /search.json?q=\&quot;i+wish+i\&quot;+&amp;rpp=60&amp;result_type=recent HTTP/1.0&quot;;<br> <br> I basically got rid of the search and just put in &quot;I wish I&quot; for the time being.<br> <br> So, there you have it. If anyone wants to continue to improve, the army of &quot;modern&quot; Arduino hackers can start from this modified code that indeed works. (yay!)<br> <br> https://www.dropbox.com/s/ewrbhqphya64dmc/World_Mood_Nowlab.zip<br> <br> Enjoy, and please share comments as you make progress.<br> <br> Dave
Hey! I tried going to the dropbox link you gave, but the file is missing. Do you still have it up somewhere? Thanks in advance!
<p>I would love this code also. I prefer the &quot;modern&quot; arduino.</p>
<p>Great looking project, any chance it will get updated to work with the current Arduino IDE?</p>
<p>We tried replicating this on the Arduino Uno, and all of the code and libraries have been correctly added to the IDE, but we are currently getting the following error: </p><p>The libraries are correctly added as stated above. Any help is appreciated thanks.</p>
<p>This is great. I have to try doing this</p>
<p>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!</p>
<p>By the way, I'm using an arduino uno. Thankyou. Please reply. </p>
<p>excellent idea, i think the search terms could be 'work in progress' but other than that a really cool idea.</p>
How can I make this without using the WiFly module?
<p>I second you, too.</p>
<p>So can this still be done ? </p><p>If yes , do i need to buy the same hardware? </p>
What would be better is to have a &quot;mood server&quot; that calculates the mood, and have the Arduino connect to it. <br> <br>Since all the heavy work runs on the server, the mood could be updated much faster than the Arduino, and it would save battery life. <br> <br>I'd write the server software myself, except I suck at interfacing with Twitter... :P
hi so i downloaded the code but it doesn't work with processing or arduino because i have updated versions. Is there an updated version of the code in .pde and .ino format
It is a very nice project however, you constantly search for news, does it consume a lot of battery? <br> <br>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? <br> <br>As I would like to make one that ideally be waiting and be triggered so to consume the minimum power
When running this code I got errors saying &quot;WProgram.h&quot; did not exist. The solution is to replace any instance of <br> <br>#include &quot;WProgram.h&quot; <br> <br>with <br> <br>#if ARDUINO &gt;= 100 <br> #include &quot;Arduino.h&quot; <br>#else <br> #include &quot;WProgram.h&quot; <br>#endif <br> <br>(source: http://makezine.com/2011/12/01/arduino-1-0-is-out-heres-what-you-need-to-know/)
can we make this using a wifly module rn xv wifly shield
Being fairly new to Arduino and EE / Physical Computing, I am not at the stage where I feel comfortable making my own Circuit Boards. Would anyone mind posting how to wire this via breadboard?
I would love to make one of these... however $70-$100 for the WiFly shield is way too much... any other ideas that would substitute?
I'm in the same dilemma :( Wifly shields are expensive where i come from. I suppose an Ethernet shield would help?
So, i have a question. How could i accomplish this project with an Ethernet shield instead of the Wifly shield? (I ask because the Wifly shield is rare and expensive where i come from..)
a wonderful idea
Hi,<br><br>I compiled this code and getting me lot of errors..<br>plz help me!!!
This looks like a fantastic idea. &nbsp;I'll probably adapt the base and use wood, and maybe allow for USB power instead of the 9V battery as well. &nbsp;Also, perhaps an on-off switch on the back may be something I'll do.<br> <br> How long are you experiencing the 9V battery last?<br> <br> Thanks for this, it's going to get me working with acrylic, something I haven't done yet.
did you ever get the problem fixed? i had the same problem <br />
Something else to keep in mind, the Twitter API is about to change. When it does, it appears that after 5 March 2013, this code will no longer work and will require an update. <br> <br>If I figure out how to make it work again, I'll post the code here. If not..... I guess I'll hope someone else figures it out. <br> <br> <br>https://dev.twitter.com/blog/changes-coming-to-twitter-api
The Olympics stole your idea! <br>http://www.metro.co.uk/olympics/907250-twitters-olympic-mood-beamed-to-world-from-edf-energy-london-eye <br> <br>I was still excited to see the concept on the international stage.
Ha! Not the first nor the last, i suspect :D
Has anyone tried to make this with processing? <br />Or perhaps with an ethernet shield? I'm really interested!
Has anyone tried to make it work over USB cable, without Wifi?
is it possible to use a usb with a processing script?
I have nowhere near the experience to make one of these things, is it possible that I could buy one from someone, and if so, for how much?
Created a plot to track trends (1/day) based on this great project:<br> <a href="http://www.mathworks.com/matlabcentral/trendy/plots/644" rel="nofollow">http://www.mathworks.com/matlabcentral/trendy/plots/644</a><br>
Hey ! nice project, very inspiring. btw wanna ask (i'm new with this) is it possible to use ARDUINO ETHERNET SHIELD instead of wifly shield?<br><br>will the script be different?
Yes, you could go that route, but you will have to rewrite the sections that reference the WiFly Shield. There's no shortcut, I'm afraid. Change the hardware and you have to change the code.
is alright! i bought the wifly shiled.<br><br>Thanks for the reply!
I'm trying to get my twitter mood lamp to work but I keep getting a <br>'Serial' was not declared in this scope error. Does anyone know how to fix it? When I tried looking online, I came across a blog that suggested to include the Software Serial library, but that didn't seem to do anything.
The fix to that is described over at the Arduino Boards. However, we're still having timing issues to work out among other things. Follow along over here:<br>http://arduino.cc/forum/index.php/topic,65655.0.html<br><br>It also appears that these issues are more common if you're using the Arduino Duo instead of the Duemilanove.
hey awsome project :) but i keep getting error messages on the code? i have never built a project with code before so i have no idea what im doing , i have a fairly good knowladge of computers however , you think you can help?
I built the device, and it looked like it was working correctly giving me an overall mood of mild love. looking at the serial monitor, after doing the query search it shows a list of results, and on the 29th result it cuts short and says &quot;warning: failed to find EXIT&quot; and gives the line: &quot;love: tweets per min = 29.00&quot;. it does this for Love, Joy, Surprise and Anger, all giving a result of 29 tweets per min, which seems odd... I'm using an Uno with th Wifly shield.
This is amazing. For an Arduino novice like me, It worked in the first go! Thanks for this excellent contribution. I am not that familiar with the Twitter interface, is there a way to specific a country and look at the twitter moods there. It will be like a magic cube during international traveling.
This is so cool, but I'm still not going to get a twitter.

About This Instructable


610 favorites

More by RandomMatrix: Twitter Mood Light - The World's Mood in a Box
Add instructable to: