Getting started with Arduino / Rainbowduino

Posted by: on Jan 17, 2012 | 11 Comments

I recently bought some Arduino microcontroller/prototyping boards and components. The plan is to rediscover my childhood interest in electronics and familiarise myself with these tools so that maybe in future I can help teach some of this at schools. This is because I believe that its the practical stuff that can integrate with other school lessons that can give young people the best start at programming.

The great thing is that actually, with only a little knowledge, doing this stuff is really easy. The Arduino board designs and software are open source, which is a good thing. However as usual this means the docs can be problematic.

There’s a confusing array of Arduino hardware out there. The boards have the ATmega micro controller chips on them that you program, and lots of digital and analog input/outputs so you can control and measure things. There are boards with Ethernet, Wi-fi, USB and even LED matrix drivers.

Basic Arduino (UNO)

Using this Arduino which has just a USB port and the I/O connectors, plus a bread board and 4-digit 7-segment LED display from an Earthshine starter kit, I managed after digging out the spec sheet on the display, to create a counter from 0001 to 9999. This sounds trivial, but it has a few challenges:

  1. The LED display is basically 4 x 8 LEDs (7 segment + decimal point)
  2. There are only 12 pins on it. Huh?
  3. If you don’t send power to one of the LEDs, it goes off.

The spec sheet showed that 4 pins control which of the 4 digits you are addressing – set them LOW (common cathode) to enable the corresponding digit.

Then you set some of the other 8 pins HIGH to represent the digit or symbol you want to show.

So to set all 4 digits without any shift register chips or other smarts to “remember” the state of segments for each digit, you have program the Arduino to continually loop through the 4 selector pins, set the segment pins HIGH, wait a few milliseconds, then set the selector pin for that digit HIGH (to turn it off), and then repeat the same process for the next digit’s selector pin. What happens is that each digit is illuminated for say 5ms and then it moves to the next one.

They are continually going on and off, but because you constantly loop at high speed over them, it appears to be a continuous display.

Much more fun – the Rainbowduino

The Rainbowduino is a self contained Arduino board and the latest v3.0 one has built in mini-USB. So its just like an Arduino UNO but has a bunch of other controllers to drive an 8×8 RGB LED matrix with constant current (which I think means when lots of LEDs are on, they stay the same brightness). CAUTION: the LEDs are also seemingly as bright as the sun and staring at them is likely to leave you with a disturbing 8×8 grid of dots burnt into your retina.

So I bought the Rainbowduino plus an 8×8 RGB LED Matrix. The Rainbowduino is built to have the matrix directly plugged into the top of it, which is very handy.

Rainbowduino board plus LED matrix mounted on top

There are some tricks to getting this working however:

  1. Unlike the Arduino UNO, my Mac would not recognise the Rainbowduino when plugged in to USB. I had to install the “FTDI” drivers from here. Thanks to @andydavies for the tip there
  2. The docs on Rainbowduino are sketchy, and seem to be mainly targeted at an LED 3D cube rather than the matrix, and using the Processing language (which is not what the Arduino IDE uses).
  3. It turns our there are several options for controlling this matrix. You can flash your own Arduino “sketches” (programs) directly onto the Rainbowduino, or you can use the I2C serial protocol to drive the Rainbowduino from another Arduino – I am guessing this means the Rainbowduino ATMega has a custom boot loader that supports serial comms to drive the display. I may be wrong.

To solve (2) I had to find the driver code that would work with the Arduino IDE. The v3 Rainbowduino driver is here. If you save that to ~/Documents/Arduino/Libraries/Rainbowv3 or similar (for Mac OS X at least that is where it is) and restart Arduino IDE, you will see you can now insert it into your Arduino sketch using the “Import Library…” menu option.

You will then find it does not compile, complaining it cannot find “WProgram.h”. This is I think because the library is built to run with “Wiring” programming language. To fix this you need to edit the Rainbowduino.h file from the driver that you saved, and change the #include <WProgram.h> to <Arduino.h>.

After that you can use the driver, which is incredibly simple:

  1. in setup() call Rb.init()
  2. in loop() call some Rb methods such as: Rb.blankDisplay() and Rb.setPixelXY(x, y, rgbcolour)

Rainbowduino with diagonal spectrum

Why so dark? LEDs are too bright to photograph without a filter. I put lots of tissue paper over them.

So here’s an example to apply the colour spectrum diagonally to the entire grid in action:

View the code on Gist.

Note that if you find your reds are not working you probably have a C typing problem, and need to explicitly cast your values to uint32_t to avoid the RR of your RRGGBB being lost to 16bit accuracy.

And seeing as most of my life is spent in Grails… this wouldn’t be complete without a video of the Grails cup shining in all its 8×8 glory.

And here’s the code, if you want some Grails glory yourself:

View the code on Gist.

 

11 Comments

  1. Jesse
    January 26, 2012

    I still cannot flash my rainbowduino. Using lion with arduino IDE 1.0. It show port /dev/tty.usbserial-a100n00b but when I try to flash it says the port is already in use. Any suggestions

    Reply
    • Marc Palmer
      January 26, 2012

      Did you install the FTDI drivers correctly? On mac they show up as usbmodem I think. Perhaps you’ve selected the wrong one, or have some other software that is detecting and attaching to the serial port?

      Reply
      • John Dale
        January 26, 2012

        Hi–if you load Arduino 0023 it will work, we are all waiting for p;athces to the arduino 1.0 to solve the wiring library issues amongst other things. I am using arduino 0023 on a PC or Mac and it also does seem to work better withe the Duemilenove (spelling?). JD

        Reply
  2. Ryan Longo
    May 23, 2012

    I can’t get my Rainbowduino to flash. What board do you choose from the menu?

    Reply
    • ukicar
      January 18, 2013

      you have to chose Duemilanove atmega328. You need also switch turned to USB not to HOST.

      Reply
  3. Bob Gallant
    June 24, 2012

    Marc — Thank you for your posting. I have been working for about a month to get my rainbowduino working. I followed your directions and Voila! Both my 4x4x4 cube and 8×8 matrix display with gusto. Most of my errors were due to inexperience. Nonetheless there are not a lot of resources available, especially recent postings. Cheers & Regards — Bob in Baton Rouge

    Reply
  4. Stevo
    June 28, 2012

    All working fine (Rainbowduino v3.0b)

    Reply
  5. aubrey
    July 29, 2012

    i am a newbe, but i have been trying to get my rduino to upload anything for about a year..ive switched ports, and tried diff. boards off the tools ,,, but none of the sketches verify…even the ones provided…i also have the mtxcontrol modual and i would like to get that to work too. …any suggustions.

    Reply
  6. Daniel Kang
    September 3, 2012

    Hey just wanted to leave a thank you for your post! Really helped this project going quickly.

    Reply
  7. mr-g
    November 2, 2012

    hi there, great help here thanks…. but do you also know how to access 2x rainbowduinos linked together? i cant find any info about this! id also like to leran how to control the rainbowduino from another arduino board if possible? the online docs are so vague :(

    Reply
  8. Chris
    November 16, 2012

    On OSX (10.6) when using Rainbowduino and Arduino IDE 1.0 with the meantioned FTDI Drivers, select ‘Duemilanove’ as the board and ‘/dev/tty.usbserial-A100X0RH’ as the serial port.

    Otherwise I got ‘avrdude: stk500_getsync(): not in sync: resp=0x1c’. Now its working pretty well. So thanks for introduction.

    Reply

Leave a Reply