RGB's with Arduino and Processing

 by nazdreg2007
Featured
DSCF5335.JPG
DSCF5331.JPG
Here is an easy(enough) project to introduce you to the Arduino microcontroller, as well as Processing. This is my first Arduino and Processing project and I didn't have too much bother getting it working.

This is my entry to the Sparkfun Microcontroller contest so if you think it's good, please vote!!(voting starts the 14th feb). Thanks!!

 Once everything is set-up, you will be able to control the color of the RBG's from your computer, using the Processing program, and also see the output color in the program( it ain't perfect but it's handy if you want this for remote lighting)

Below is a screenshot of the Processing executing. By clicking (and/or holding) on the up and down arrows, you can change the color levels of each of the colors in the RGB.

 
Remove these adsRemove these ads by Signing Up

Step 1: Equipment

A computer with Arduino and Processing. Try to get the most up-to-date release
http://arduino.cc/en/Main/Softwar e and http://processing.org/download/

An Arduino(make sure it has PWM outputs, which is all/most)

RGB Led's

Resistors(100x2 ,180x1)

Jumper wires

Breadboard

USB cable(for the Arduino)

If you are using more than one RGB, you may need to calculate the different values for the resistors. Follow this tutorial http://www.sparkfun.com/tutorials/219 or use this site http://led.linear1.org/led.wiz to calculate the required resistances.

FireCGun says: Jun 5, 2013. 1:06 PM
can some one plz tell me how i can download the code?
my computer keeps saving it as .tmp and i cant change it.
nazdreg2007 (author) in reply to FireCGunJun 8, 2013. 7:35 PM
See if you can open the .tmp in notepad. if that doesn't work, when you download, "save as" and in the dropdown select .txt.....that should hopefully work
Darkkeep says: Apr 3, 2013. 4:24 PM
Love the concept...get's your hands dirty with two great IDE platforms. I'm currently working on a project that will call for certain light spectrums for growth phases. Excellent DIY. I may post some of the code when I get a working prototype. What I'm developing is more than a weekend project ;-) Despite on how you're sending the info...still impressive.
adellelin says: Mar 28, 2013. 12:03 AM
Hi, really excited by this project, however it's not running for me on processing. I'm using 1.5.1 does the code need to change for that? This is the error code I'm getting, just wondering if you can help. Thanks!!

Display 0 does not exist, using the default display instead.
Mar 28 18:02:48 yingxis-MacBook-Pro.local java[16626] : CGContextGetCTM: invalid context 0x0
Mar 28 18:02:48 yingxis-MacBook-Pro.local java[16626] : CGContextSetBaseCTM: invalid context 0x0
Mar 28 18:02:48 yingxis-MacBook-Pro.local java[16626] : CGContextGetCTM: invalid context 0x0
Mar 28 18:02:48 yingxis-MacBook-Pro.local java[16626] : CGContextSetBaseCTM: invalid context 0x0
WARNING: RXTX Version mismatch
Jar version = RXTX-2.2pre1
native lib Version = RXTX-2.2pre2
[0] "/dev/tty.usbserial-A6005kTq"
[1] "/dev/cu.usbserial-A6005kTq"
[2] "/dev/tty.Bluetooth-PDA-Sync"
[3] "/dev/cu.Bluetooth-PDA-Sync"
[4] "/dev/tty.Bluetooth-Modem"
[5] "/dev/cu.Bluetooth-Modem"
java.lang.NullPointerException
at java.io.DataInputStream.readInt(DataInputStream.java:370)
at processing.core.PFont.(PFont.java:319)
at processing.core.PApplet.loadFont(PApplet.java:4199)
at sketch_130328b.draw(sketch_130328b.java:66)
at processing.core.PApplet.handleDraw(PApplet.java:1631)
at processing.core.PApplet.run(PApplet.java:1530)
at java.lang.Thread.run(Thread.java:680)
Invalid memory access of location 0xb20c4b70 eip=0x547f290c
nazdreg2007 (author) in reply to adellelinMar 31, 2013. 10:53 AM
Hey, sorry for the delay. It looks like to me that there may be a problem with your install of processing. maybe try a clean reinstall and see if that helps.
I used an older version of processing but i don't think the code would need much or any editing to run on 1.5.1......As i said, it looks like an install problem. Lemme know if that works
He11uvaCook says: Feb 11, 2013. 10:41 AM
This is a great Instructable! How hard would this be to connect the Arduino to an Android device via bluetooth or wifi to control the LED color from my phone?
nazdreg2007 (author) in reply to He11uvaCookFeb 13, 2013. 2:48 AM
I don't think it would be too hard....the bluetooth would probably be the easiest way because as far as i know, no extra code is needed on the arduino side....for wifi there would be but nothing drastic. The Processing code itself can be used to create an android app so with the necessary mods for the bluetooth, you should have the system running quickly.
Nman120 says: Jul 16, 2011. 1:56 PM
in your processing code download there is an error that I found:

in the text for over the arrow buttons:
text(s, 30, 100, 40, 20);

the end 20 needs to be 30 or else only the blue shows up. great program though
nazdreg2007 (author) in reply to Nman120Jul 19, 2011. 2:39 AM
Hiya,
I not noticed any probs with it......but i'll have a look over the next few days and get back to you :-)
32teeth says: Jun 7, 2011. 7:00 AM
as for your pin mapping to the PWM pins.
i would recommend using 9,10,11 since they are next to each other.
just a thought

good stuff
nazdreg2007 (author) in reply to 32teethJun 7, 2011. 1:55 PM
Thanks.
Your right.....I never thought of that. I started at 3 and went for the next PWM pins.
RPKH says: Feb 20, 2011. 8:16 AM
Is there a specific reason why you have chosen to send the values for r,g,b over the serial instead of using the arduino library in processing?
nazdreg2007 (author) in reply to RPKHFeb 20, 2011. 3:43 PM
Yeah, the processing library could have made things much easier....I'll update with some new code to use it..
nazdreg2007 (author) in reply to RPKHFeb 20, 2011. 3:26 PM
There is no specific reason for sending the data this way. It never occurred with me to use that library. Might look into it.
beverageexpert says: Feb 2, 2011. 6:04 PM
I am getting an error in processing
saying it cannot load this font AngsanaNew-25.vlw

then this line is highlighted
font = loadFont("AngsanaNew-25.vlw"); // import the font(tools->create)

nazdreg2007 (author) in reply to beverageexpertFeb 3, 2011. 11:18 AM
ok, first of all, click on tools then create font. this will open up another window. in this window, select the font and size.tke note of the filename(ctrl +c) and click ok. now paste the file name into theloadFont("
bend in reply to beverageexpertFeb 3, 2011. 11:16 AM
the answer is in your comment, go to tools, then create font, then choose AngsanaNew and make it size 25 then click "ok" and try to run the code again
tigerbomb8 says: Feb 1, 2011. 3:23 AM
i would vote but i can not see this in the contest page
nazdreg2007 (author) in reply to tigerbomb8Feb 1, 2011. 7:26 AM
Thanks!! It's still waiting for approval for entry so maybe if you try later on today or tomorrow, it should be there. Thanks again!!
tigerbomb8 in reply to nazdreg2007Feb 1, 2011. 6:47 PM
cool and why did you put thins in the micro controllers section there is an arduino section
nazdreg2007 (author) in reply to tigerbomb8Feb 2, 2011. 3:08 AM
To be honest, i forgot cause i entered this in the micro controller contest, so thats what i was thinking, not Adruino.
tigerbomb8 in reply to nazdreg2007Feb 2, 2011. 5:31 AM
you can move it
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!