Skip to content

Understanding the Rainbowduino Controller by Seeedstudio

As you may know, I’ve orderd a Rainbowduino from Seeedstudio. They delivered quite fast and I’m very happy of the price/quality/functionality ratio. In my opinion, the Rainbowduino is the cheapest ready-to-go 8x8 RGB LED Controller Set at the moment - for just 43.4$ ( 19.90$ Board + 23.50$ Matrix) you are set for taking of!

My first tests went quite well. The Rainbowduino comes with a ready to use the program/sketch which allows you basic controls via I2C bus easily, like writing letters & lines in different color and light strength. But soon I hit the limits when it came so single control each LED to my will. So no doubt, I had to dig deeper in understanding how to control the Rainbowduino. Here a short summery of my results:

To understand how the Rainbowduino works, I kind of reverseengineered the sketch by seeedstudio which came with the controller. As usual for driving those Matrixes, PWM is used as basic concept. This means the frame image is created row by row by high frequency, so human eye puts it all together to one single image.

To simplify this process I created the Rainbowduino.h Library, which comes with some nice methods to set frames and draw those to the Rainbowduino. It’s part of the mtXcontrol firmware an can be downloaded from github

How it works:
To tell rainbowduino which row to draw the method ‘open_row’ is called. As each row is represented by a one output PIN, this method sets the according PIN to high, all others to low. Unfortunately the row pins are not all on one port: rows 1-3 are on PORTB Bit 1-3, rows 4-8 are on PORTD Bit 4-8. This makes the method kind of bit ugly ;-)

After the row is selected, its time to set the pixels. One pixel consists of 3 LEDs: red, green & blue. Each LED has to be separately to high or low to mix the final color (e.g. red + green is yellow). First all blue values of a row are set, then red and finally green. This happens in serial on PORTC. First bit is the value input, second bit is clock, bit 3 the write mode bit and bit 4 to display the shifted value. Call the method ‘draw_row’ to display a row. First parameter is the row number (0-7), second the intensity (1-16) and then the red, blue & green values for the row. e.g passing the color values 1,0,0 would light the first pixel red and all other off, where as 255, 255, 255 would light up all LED and all colors, to the full row would be white.

To store the row values the Library comes with a frame buffer for 10 frames. (That the amount of frames we can store to EEPROM without compression as well). You can pre fill the buffer and set the frame number to display. By calling draw() the frame of the current _frame number is drawn.

It makes sense to call this function by a timer interrupt to not disturb your actual program progress and to ensure it’s call in regular frequency to avoid different display colors.

To set up the timer, include this in your code:

Rainbowduino rainbow = Rainbowduino(10); //max 10 Frames

void setup_timer() {
TCCR2A = 0;
TCCR2B = 1<<cs22></cs22> TIMSK2 = 1<<toie2></toie2> TCNT2 = 0;

ISR(TIMER2_OVF_vect) {

Now, just fill you frames with

rainbow.set_frame(0, *data);

and your’re ready to go. Have fun!

First tests of the library with earlier version of mtXcontrol, an Editor to create images on the Matrix easily:

Stay tuned for more examples soon…