Skip to content

Understanding the Rainbowduino Controller by Seeedstudio

October 02, 2009

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…

Nabaztag:tag arrived - meet Nabaccia!

September 29, 2009

Yay, my new toy has arrived: It’s a Nabaztag. Short story: I first met the rabbit in 2007 at re:publica conference @ Berlin, and always want to have one since then. Nabaztag is a rabbit connected to the Internet with moving ears, 4x color LEDs, a RFID reader, a button and Sound In & Output. It’s hard to understand why one wants to have such rabbit, but the idea to connect things with the internet sounds very interesting to me. But just for playing around, it was to expensive … till now!

Sadly (well, luckily for me) Violet, the producer of Nabaztag, is on it’s way to bankruptcy. As of this MyRobotcenter started selling them half price - nice! I couldn’t anymore resists buying and got the rabbit+mirror+zstamps for a good price - that’s all right!

According to violet, each thing needs a name, so mine is called Nabaccia , listens to emails via nabaccia - and, of course, twitters here as well. So, now it’s time to hack the rabbit. I saw a couple of interesting project out there, let’s get it on! More on this soon!

I know it’s totally wired and hard to understand why, just don’t ask ;-)

Image by Liron - thx!

Rails flag_shih_tzu Plugin with named_scope

August 20, 2009

When it comes to store a load of boolean data into your model you easily end up with lots of columns which blow up your table unnecessarily. The developers at Xing solved this problem with a nifty Rails Plugin called flag_shih_tzu. The trick is to store all boolean values combined as a bit vector, which allows you to put up to 32 values (4Byte) within a single Integer column. Automatic generated access methods allows you to deal with you model as your are used to. Wanna see an example? (Taken from plugin docs)

class Spaceship < ActiveRecord::Base
include FlagShihTzu

has_flags 1 => :warpdrive,
2 => :shields


enterprise =
enterprise.warpdrive = true
enterprise.shields = false

enterprise.warpdrive? #=> true
enterprise.shields? # => false

Nice, isn’t it?

Unfortunately named scopes where missing for selecting models easily. So another github fork, another fix, and here were are. Now this works as well:


Check it out here:

Update: replaced ‘routes’ with ‘scopes’ - I’m getting confused with that all the time, how come!? ;-)

Quake like Terminal on Mac OS X: Visor Plugin

August 14, 2009

Sure you do remember Quake. And sure you di remember how cool the console faded / slided in from the top? Image this would be available for your Mac OS X Console/Terminal. Well now (actually since ages, but I just forgot to mention ;-) it is. As small SIMBL plugin called Visor Plugin allows to to bring up the Terminal via a hotkey in anytime. I really love it and can’t without it anymore.
Check it out here:

Extending Active Scaffold as_paperclip_bridge to delete & update image/attachment

August 13, 2009

As you know I’m quite fond of working with Active Scaffold (AS) for data administration proposes. Quite recently we moved over to the RoR paperclip attachment plugin for file upload handling. I was even more happy to see a Active Scaffold bridge which integrates paperclip smoothly into AS as well. It’s created by and hosted here on github.

Unfortunately it didn’t provide the possibility to delete or update an image once it’s assigned to an object. Well no problem, another fork of mine, some coding and now it possible. I basically reused to code of the as_file_column_bridge. Check it out here:

Update: changes got merged into trunk, check it out:

Stealth Project on a Nova 10x10x10 LED Cube

August 10, 2009

Hey guys, look at this: I just found this awesome project by Squidsoup. They put up a 10x10x10 LED Cube “NOVA 3D LED” (yes, 3 dimensions, yes that’s 1000 single controlled LEDs) and created cool stuff like webcam projection or a the “Stealth Project” , a game similar to Battleships. Just get it’s great sounds and projections:

More on this here:


Beginners Guide to Arduino - free PDF Download

July 30, 2009

Earthshine Design just released a free Beginners Guide to Arduino as PDF download.

Feel free to grab it here: Earthshine Design Arduino Starters Kit Manual.

It covers several experiements you’ll start your Arduino career with, especially you’ve bought thier very complete starter kit. Go for it!

[found via]

RainbowDuino here it is! (and how to program it)

June 25, 2009

Yay - I finally got my RainbowDuino. Unluckily I did sth wrong with the external power connection (JST 2 pin jack) and smashed a capacitor. Maybe the polarity was wrong or it couldn’t stand the 12 volts? But luckily no damage to the main system so it still works using the terminal connector (right through the 5volts of the Arduino). *phew*

The first real basic problem I ran into was how to program the Rainbowduino as there’s no USB connector and I don’t have an UART interface.
But well, nothing simpler than that: Just connect your Arduino’s Tx,Rx,GND,Reset and Vcc ports with those of the Rainbowduino, choose the right controller type in your IDE and program it as usual - works perfect for me!

Check out my Rainbowduino Editor mtXcontrol here - it’s an easy way to draw shapes on your rainbowduino!

Btw. DTR on Rainbowduino is Reset on Arduino

Sorry I forgot to mention, this trick does NOT work if your host arduino is a ATmega168 - you need an ATmega328 to pass serial communication through. Before that, make sure you upload this blank sketch to your host Arduino first:

/* blank sketch to upload on Arduino */
void setup()

void loop()


And, as multiple times requested, a picture of my complete setup:

Make sure you’ve selected the switch right. It has to point to the same side as the green Terminal connectors are. If you power rainbowduino through the white JST jack, flip it!

MySQL: How to swap entires of two columns with just one query

June 24, 2009

Check this out, I found out a really nice way how to swap values of two columns with just one query, using user defined variables. Given a table with two columns a and b. To swap their values in whole, use this query:

UPDATE my_table SET a=@tmp:=a, a=b, b=@tmp;

Done! Isn’t that easy?

Pimp my TextMate: how to speed up search & load

June 18, 2009

As a true Ruby on Rails developer you probably work with TextMate, as it’s a plain, simple, but yet quite powerful editor. I love its open-file-by-pattern (?+T) or find-in-project (?+?+F) functions. But one thing which bothered me the most was the search time when working on big, large, massive projects. One easy tweak how to speed it up easily is to extend the file and folder exclude patterns. For example you don’t need the tmp, log or vendor folder, nor any binary files within your editor. So I just excluded them, here are my new patterns (all in one line):

Files: (excluded all images,pdf & flash)

Folders: (exclude tmp tools vendor uploads lang locale po old_migrations script images upload custom_maps log)

To change the settings go to
preferences -> advanced -> folder references

Yeah, now my search is quite fast again!

RainbowDuino - I'm comming

June 11, 2009

Yeah! Just ordered a bunch of stuff from the Seeedstudio Shop, my new favorite Arduino parts dealer. I’m really looking forward to get the RainbowDuino into my hands. I’ve already order thier 8x8 RGB LED Matrix at ebay which is really promissing… Unfortunately they are located in china to shipping takes ages ;-( More soon to come ….

A short evaluation of open source Newsletter/Mailinglist Software

June 09, 2009


A friend of mine asked me which newsletter system to use for sending abt 2k emails abt once a week. I couldn’t immediately respond, so I gave it a small evaluation of current products. As prerequisite, the system should be in active development, run on a (web)server, easy to use (usability over features) and it would be nice to use it at lowcost or for free. This limited the selection a lot and I just want to present my final opinion:

My favorite and ‘winner’ is the Simple Mailing List. It’s written in PHP, simple, clean and really easy to use. Perfect for a small use-case like this. Check it out:

Actually I thought PHPlistis first choice, but I didn’t liked it usability at all - I wonder why it’s so popular?

OpenEMM has a nice website and pretends to be opensource, but somehow I wasn’t able to get a proper version to run and test. Looks more like fake to me… Update: see comments, apparently there’s lot’s of work going on and you can download it from sourceforge easily..

MailMan is quite popular, known as stable and high performant, but still I don’t like the backend. The whole software looks a bit outdated to me… c’mon it’s 2009!!!

Other systems may worth a look as not for free, so I didn’t test them:

Nice sources to check:

Event to be: Art vs. Technology Workshop Berlin

June 08, 2009

Just found this nice event, taking place from 20-21. June in Berlin, organized by the Tinkersoup people:

Unfortunately I may not be able to take part. Damn! ;-(

My first GitHub fork: bounce-email

June 05, 2009

Hurray! I finally forked a github project. Yesterday I ran into the bounce-email gem by Agris Ameriks on Rubyforge. It’s basically a 1:1 port of the PHP Bounce Handler classby Chris Fortune and not very rubyified. Thanks to David Reese, bounce-email is forked on github and I could easily extend it.

I rubyfied the class, did some code cleanup, added (yet a very simple) way to get the original message, and gained some performance by paring message only on demand. A testcase was broken as well the Rakefile, both are fixed. See the update here:

Arduino: Fade and pulse a LED with just using a DigitalPort

May 17, 2009

This is a nice experiment I did to fade and pulse a LED by just using a digital port. Digital? On/Off, 1/0 - how can this work? Well it does, check this out:

The key is, I’m switching the LED on & off very fast which appears the human eye as it’s on all the time (similar to a LED Matrix). Now, I change the time period between switching the LED on and off. Is the off period time longer, the LED lights low, is the off period time short, the LED lights high. Fading the period time, makes the LED pulse… nice!

Check this (still quite ugly) code:
int ledPin = 13; // LED connected to digital pin 13
int value = LOW; // previous value of the LED
long cnt = 0; // will store last time LED was updated
long low = 0; // interval at which to blink (milliseconds)
long high = 1000; // interval at which to blink (milliseconds)
int op = 3;
long a = 0;

void setup()
pinMode(ledPin, OUTPUT); // sets the digital pin as output

void loop()
a += op;
blinkl( a+30, 10 );
if( a > 200 || a < 0 ) op *= -1;

void blinkl(long low, long high )
int c = 5;
while ( c > 0 ) {
blink( low, high );

void blink( long low, long high )
long period = 4000;
long pt = period * high / (low + high );
int value = LOW;
digitalWrite(ledPin, value);

while( period > 0 ) {
if (period < pt && value == LOW ) {
value = HIGH;
digitalWrite(ledPin, value);
period -= 1;