I bought two Rainbowduinos from seeedstudio and wanted to play a bit. A Rainbowduino is basically a 8×8 led matrix driver with a I2C interface. This image shows two rainbowduinos, each with a 8×8 RGB Matrix, in action:
I used my Processing library and some custom Java code (using rxtx library) to display animations (amongst others is use the blinkenlights library) on the rainbowduino. This little video is the outcome after some hacking:
2xrainbowduinos + 1xarduino = fun from michu on Vimeo.
preview of my rainbowduino/arduino firmware and the java tool to create some fancy stuff…
I use an Arduino (Duemilanove) as serial / I2C gateway, here is the wiring scheme:
I published my firmware (Arduino firmware, Rainbowduino firmware and processing library) at google code.
GPL’ed source: http://code.google.com/p/neorainbowduino/
My firmware is more or less a rip-off of the “daft punk” firmware by Scott C / ThreeFN (Rainbowduino firmware) and the blinkM firmware (Arduino) firmware. I removed unused code as I keep my Arduino/Rainbowduinos stupid – I just want to send frames from my workstation to the Rainbowduinos. I had to add some sanitychecks to the Rainbowduino firmware to make it stable.
Here are some features of the firmware:
- Send buffer from your workstation to the Rainbowduino
- Stable, running more than 5h (at 115’200 baud)
- Fast, more than 50 fps with two Rainbowduinos possible. One frame needs ~100 bytes
- Multiple Rainbowduinos supported (I2C protocol)
- Heartbeat, the Arduino tells you each second if he is still alive and its error counter
- Processing library availble to mess with Rainbowduinos
How to use the Firmware
1) Install Arduino IDE
Get the latest Arduino IDE from here, and install it. You also need to install the MsTimer2 library.
2) Patch Arduino I2C library
Per default the Arduino I2C protocol uses 100kHz to communicate – we need 400kHz. The detailed how-to can be found at the Arduino Forum, here is a short step by step introduction:
The atmega-hardware can do 400 KHz, but you have to tweak the Wire-library in file hardware/libraries/Wire/utility/twi.h. Near the top of the file you see:
1 2 3 | #ifndef TWI_FREQ #define TWI_FREQ 100000L #endif |
If you change that to
1 2 3 | #ifndef TWI_FREQ #define TWI_FREQ 400000L #endif |
The I2C bus should now run at 400kHz. But you also have to the delete the files hardware/libraries/Wire/Wire.o
hardware/libraries/Wire/utility/twi.o because the library must be re-compiled before it uses the new speed.
(This is done automaticaly when you open the Arduino-IDE)
3) Wire up Arduino/Rainbowduino
Connect your Arduino serial ports with the serial port of the Rainbowduino:
(img source)
This allows us to flash the Rainbowduino with the Arduino IDE (I use Rainbowduinos with an Atmel 168 uP, NOT the 328!)
4) Update Rainbowduino Firmware
Upload the Rainbow_V2_71.pde firmware to the Rainbowduino (select ATmega 168 board). Remember to change the I2C adress for multiple devices, the I2C adress is specified in the Rainbow.h file:
1 | #define I2C_DEVICE_ADDRESS 0x06 |
5) Update Arduino Firmware
Upload the neoLed.pde firmware to the Arduino. I had to disconnect the Rainbowduinos
rx/tx lines – else the upload failed (do not forget to select ATmega 328 board). If you changed the I2C adresses of the Rainbowduino slaves do not forget to change the initial part:
1 2 3 4 | //clear both rainbowduinos - //hint init will fail if both rainbowduinos are not available! BlinkM_sendCmd(0x06, serInStr, 96); BlinkM_sendCmd(0x05, serInStr, 96); |
6) Connect I2C Bus
For I2C, you need 3 cables (SDA,SCL,GND):
- (+) and (GND) from Arduino to Rainbowduino I2C pins.
- Arduino analog input 4 = Rainbowduino I2C SDA
- Arduino analog input 5 =Rainbowduino I2C SCL
Additional Information: I2C cable length
Summary from http://www.i2cchip.com/i2c_connector.html#Bus%20Length
- Use screened and twisted cable for runs between boxes. DON’T twist SDA and SCL together. Look at our bus, and either pair them with gnd, or pair SDA+VDD and SCL+GND
- Don’t run the bus fast if you don’t need to
- Run the bus at higher currents
- Cable length maximal 8m
Useful links:




[...] This post was mentioned on Twitter by Vincent van Haaff, Tech news (BOT). Tech news (BOT) said: Reddit/p: 2x rainbowduino with a rgb led matrix + 1x ardiuno + some java code = shitload of fun! http://bit.ly/d4plGS [...]
The title of
4) Update Arduino Firmware
and
5)Update Rainbowduino Firmware
should be exchanged.
Thanks! It’s fixed now.
[...] the resources and codes you need to make the same effect, click below link for the original post: http://www.neophob.com/2010/07/rainbowduino-fun-aka-neorainbowduino/ VN:F [1.9.3_1094]please wait…Rating: 0.0/10 (0 votes cast)VN:F [1.9.3_1094]Rating: 0 (from 0 [...]
OK look. I’m an artist, I have cool ideas to do for rainboduino but I don’t have the head for all these complications. I just want to tell each led what color to be, how bright, and for how long. Is that too much to ask? How much would I have to pay you to set it up for me?
hello can you help me please I don’t know how to run rainbowduino.java I’ve done as you said but now i’m stuck
hey
to initialize the rainbowduino device, use
2
3
4
5
6
private boolean ping;
...
rainbowduino = new Rainbowduino( papplet );
rainbowduino.initPort();
ping = rainbowduino.ping((byte)0);
then send a frame to the rainbowduino:
cheers
I’m really new to anything java and still don’t understand sorry. I’ve got a rainbowduino hooked up to my arduino with everything ready I want to stick to what your doing as your active I see your updating stuff on google code all the time. Do I need a java ide I don’t know where to write that code Please help me
Currently you need to use eclipse, as my processing plugin is not yet finished. You need to use some Processing libraries and the serial libraries (librxtx).
I’ll provide some examples, once I’ve finished the processing lib.
regards
Thank you I did install eclipse last night I’ll follow some tutorials to get me started I’m looking forward to playing with the rainbowduino using my laptop Thanks for your help.
[...] for each rainbowduino! Upload the Arduino firmware to you Arduino, wire up the whole stuff (check my last post about neorainbowduino how to connect the [...]
Wow, this is cool stuff. Great job. I followed the breadcrumbs back to your blog after seeing your comment. How many fps can you get with this set up?
A bit about arduino’s twi lib – it is interrupt based implementation which I found to be rather inconsistent when I tried to use it on barebones atmega chips. I had it working with Wiinunchuck, but it was pain to get it working. This thread has some good info:
http://www.nerdkits.com/forum/thread/972/
If you don’t mind doing s bit of C coding outside of arduino IDE, i recommend: http://homepage.hispeed.ch/peterfleury/group__pfleury__ic2master.html
This one uses polling mechanism and discard interrupts all together.
I also had some issues with arduino’s twi lib, the interrupts disrupted by display function if too much i2c data were send. however I worked around this issue by limiting the data I send to the device – I send only changed frames to the device (using md5 checksum). To send an RGB image to a rainbowduino currently takes about 20ms – so per arduino I can send out 50fps. I save about 50% using my checksum function, means you get “virtual” 100fps.
hi, nice library. your firmware for the rainbowduino is clearer to me than the other ones I’ve found so I can actually try to understand what is going on and try to program my cube to do something interesting.
I’m curious, how does gamma correction work with your firmware? i can’t find a reference to it in the code.
also, any idea how to use more than 16 color levels per channel? the colors step noticeably for me.
hey greg. the original “gamma correction” was done by displaying the first brightness level longer then the 2nd brightness level etc. I didn’t like that and choose to use a gamma lookup table (its in the java library: http://code.google.com/p/neorainbowduino/source/browse/trunk/processingLib/src/com/neophob/lib/rainbowduino/RainbowduinoHelper.java). With this map you can improve the coloring (the comment from the blog entry: PWM from 0 to 100% duty cycle is accurately changing brightness in a linear way, the eye sees almost no difference between 75% and 100% brightness).
And I guess you cant use more than 16 color level per channel – as this is a hardware limitation. I didn’t try it though.
hi, ive been trying to upload the firmware to my rainbowduinos for months through an arduino uno and i cannot get it to work at all, how to i get it to work? or am i using the wrong kind of arduino board?
did you upload an empty sketch to the arduino uno previously?
yes, i had to consult an admin from the seeedstudio forum to get it to upload using a specially altered sketch, but now i cant get neorainbowduino to load up onto either of the boards, the programmer throws back errors
[...] hakkındaki ayırntılı bilgilere buradan, Rainbowduino wiki sayfasına ise buradan [...]
Hello, what happens if my rainbowduino uses the atmel 328?? should i do something different?
Not really, why do you think?