Instructables

Controlling an RGB Led with Arduino and Processing

Step 3: Software

Picture of Software
RGBR.png
So whats going on. basically we've set the arduino up to respond to a particular message. this message consists of a header (the letter "C") a dud byte (some strange serial problems caused this to be implemented) and the bytes of data (R G B respectively)

All processing is doing is generating these messages based on a pixel in an image, when we click the mose location is recorded and the message is built and sent to the audrino over a serial connection.



See the attached files for the software for this project, hitting run in processing should bring up a screen like the one below, although it will depend on what image you choose to load.

ColourMap goes in processing

RGB_LED_arduino_code goes in (you guessed it) arduino.

Make sure you load this onto the arduino before you run the processing file or it wont do anything.

if you having trouble check the following:

Is the arduino plugged in
is the arduino power light on
have you wired the led correctly
have you chosen the correct serial port in processing

if your still having trouble post a comment below and I'll do my best to answer it.
 
Remove these adsRemove these ads by Signing Up
bodet3281 year ago
I know I'm really late to this, but why is the red part of the colour map blocked off?
supralova112 years ago
Thank you so much :)
cmanrique2 years ago
dude im having problem with the color map  ,  please help me with that  and dude this is a n awesome project

Zedone Two2 years ago
Could you do an instructable with both an xBee and RGB LEDs? I'm interested to see it work, especially controlling the LEDs separately and wirelessly at the same time :D
32teeth2 years ago
works well if you change your serial ports
arduino's serial port will be whatever your COM port for uploading the file will be
on processings side the index will changed based on your OS and how many things you have plugged in

on OSX you will get many com ports (usually between 5 and 8 depending on whats plugged in) look for the first one that has TTY in it's property

on PC they will show up as COM1, COM4...

good starting project on communications between software and hardware.
it doesnt work.....I cant find the image for processing and I keep getting a "Null pointer exception" what is that ? I think your code is bad or something...please respond....
pdunandf3 years ago
great example thanks - having problems with getting the right colour from processing to arduino but it is a matter of patience, I guess
clawlor883 years ago
I've had no problem with calibrating or uploading the image. However, i'm getting this error when I try to run the file:

"error: 'import' does not name a type In function 'void setup()':
In function 'void draw()':
In function 'void mousePressed()':"

Anyone know this means? Thanks for any help!
scottyb49963 years ago
I am confused. How do I get Processing to open up the picture? Basically where do I put the image and the code at?
whiskey_143 years ago
this is pretty sweet, thanks for sharing!
PoisonMondo4 years ago
what do you mean by processing
Processing is a multi-platform programming IDE based on Java. It's at processing.org. It's pretty simple to learn and has great support via their forums and the web in general. Terrible name though since it's such a generic word!
CCOTTER2473 years ago
The software wont work!! Help! It downlaids a a .tmp file and processing and arduino doesnt recognize it!
left click the file and press rename, then select tmp and enter pde when the open menu asks " if the file extension is modified the file might become unusable..," press yes. do this with both files and i am pretty shure the one ending in 2K is arduino c code, the other is for prossessing.
Thank you! I how have it working!!! How do I calibrate the color?
You need to make a another background file and import it into processing, or if your asking to change the LED's colour, just run the program and click on the colour you want to change the led into.
I apologize for not being very clear on my last question! I was curious about calibrating the color of the led. When I click a color on the screen it changes the led to a different color than I clicked on. Any suggestions?
try turning on any single colour(red, green, or blue), then disconect all and put each pin of led into the arduino pins, once you get a matching colour leave it connected, do the same procedure for the next colour.
smitec08 (author)  CCOTTER2473 years ago
check the pure RGB values (red blue green) if they seem correct then you know the pins are correct. if they seem a bit off check if you have a common anode of cathode LED. that will change the code if its common anode attach the common anode to VCC and wherever there is an analog out replace its value with 255- that value eg analogOut(X) to analogOut(255-X) if that still doesnt fix it check you resistor values with an online calc to ensure they're in the right range as it may be letting to much power through to the LEDs. Hope that helps. Smitec :D
PoisonMondo4 years ago
where s the picture file and your code didn't work
PoisonMondo4 years ago
for the serial part
 myPort = new Serial(this, Serial.list()[0], 9600);
is that your com port
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!