I bought two Rain­bow­duinos from seeed­stu­dio and wanted to play a bit. A Rain­bow­duino is basi­cally a 8x8 led matrix dri­ver with a I2C inter­face. This image shows two rain­bow­duinos, each with a 8x8 RGB Matrix, in action:

 

I used my Pro­cess­ing library and some cus­tom Java code (using rxtx library) to dis­play ani­ma­tions (amongst oth­ers is use the blinken­lights library) on the rain­bow­duino. This lit­tle video is the out­come after some hacking:

2xrainbowduinos + 1xarduino = fun from michu on Vimeo.

pre­view of my rainbowduino/arduino firmware and the java tool to cre­ate some fancy stuff…

I use an Arduino (Duemi­lanove) as ser­ial / I2C gate­way, here is the wiring scheme:



 

I pub­lished my firmware (Arduino firmware, Rain­bow­duino firmware and pro­cess­ing 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 (Rain­bow­duino firmware) and the blinkM firmware (Arduino) firmware. I removed unused code as I keep my Arduino/Rainbowduinos stu­pid — I just want to send frames from my work­sta­tion to the Rain­bow­duinos. I had to add some san­i­ty­checks to the Rain­bow­duino firmware to make it stable.

Here are some fea­tures of the firmware:

  • Send buffer from your work­sta­tion to the Rainbowduino
  • Sta­ble, run­ning more than 5h (at 115’200 baud)
  • Fast, more than 50 fps with two Rain­bow­duinos pos­si­ble. One frame needs ~100 bytes
  • Mul­ti­ple Rain­bow­duinos sup­ported (I2C protocol)
  • Heart­beat, the Arduino tells you each sec­ond if he is still alive and its error counter
  • Pro­cess­ing library avail­ble to mess with Rainbowduinos

 

How to use the Firmware

 

1) Install Arduino IDE

Get the lat­est 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 pro­to­col uses 100kHz to com­mu­ni­cate — 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
#ifn­def TWI_FREQ
#define TWI_FREQ 100000L
#endif

If you change that to

1
2
3
#ifn­def 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 auto­mat­i­caly when you open the Arduino-IDE)

3) Wire up Arduino/Rainbowduino

Con­nect your Arduino ser­ial ports with the ser­ial port of the Rain­bow­duino:



(img source)

This allows us to flash the Rain­bow­duino with the Arduino IDE (I use Rain­bow­duinos with an Atmel 168 uP, NOT the 328!)
 

4) Update Rain­bow­duino Firmware

Upload the Rainbow_V2_71.pde firmware to the Rain­bow­duino (select ATmega 168 board). Remem­ber to change the I2C adress for mul­ti­ple devices, the I2C adress is spec­i­fied 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 dis­con­nect the Rain­bow­duinos
rx/tx lines — else the upload failed (do not for­get to select ATmega 328 board). If you changed the I2C adresses of the Rain­bow­duino slaves do not for­get to change the ini­tial part:

1
2
3
4
  //clear both rain­bow­duinos —
  //hint init will fail if both rain­bow­duinos are not avail­able!
  BlinkM_sendCmd(0x06, serIn­Str, 96);
  BlinkM_sendCmd(0x05, serIn­Str, 96);

6) Con­nect I2C Bus

For I2C, you need 3 cables (SDA,SCL,GND):

  • (+) and (GND) from Arduino to Rain­bow­duino I2C pins.
  • Arduino ana­log input 4 = Rain­bow­duino I2C SDA
  • Arduino ana­log input 5 =Rain­bow­duino I2C SCL

Addi­tional Infor­ma­tion: I2C cable length

Sum­mary 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 max­i­mal 8m

Use­ful links: