OK, now for something completely different…
Some RGB LED matrix effects -- Code: matrix_code.pde
(This code will not run flawlessly on up-to-date matrix boards without modification. Please only use this code, unless you exactly know what you’re doing.)
So far I’ve got some code using a timer1 or timer2 interrupt to do several nice effects. Maybe I’ll write some code for the device to listen to commands on the serial line.
But before that happens I need to get the PCB making process going again. It’s either toner transfer if I get the laminator hot enough, or I’ll buy some UV device to do old fashioned photographic layout transfer. What a pity that I sold one of these a few years ago. Now they cost the same numeric value in € as 10 years ago in DM.
latest schematic:
SR = 74HC595, 8bit shift register, SPI interface (clock, data, latch)
UDN2981A = current source driver to power common anode rows
Please also have a look at my projects page for the latest demo code.
Comprehensive writeup at instructables.com
Related posts:

Hi Robert,
verschenkst du sowas zu Weihnachten? :-)
Gruss Helmut
suchst du ein neues hobby ?
hi Robert, how much deep of solution in this RGB? sorry for my bad english.
Well, nominally it supports up to 32768 colors. That is 15bits (or 5bits per color).
What the effective (perceived) number of colors is, that can be discerned with your eye, is a totally different matter. I suppose that will be a lot less.
I build 8×8 RGB matrix my self. First I tested with no pwm and rowscanning that all leds work. Then I started to use your code, which I very good. Last row of my matrix does something wierd. It stays brighter than other rows.Do you know how I can fix that?
There are three things that come to my mind:
• there is a wrong current limiting resistor on the last row
• the code somehow spends more time processing the last row
• the display is not turned off outside the PWM generation
The last point exactly reproduces the error.
This is why all of the PWM code has this form:
digitalWrite(__display_enable,LOW); // enable display inside ISR
/*
the PWM code
*/
digitalWrite(__display_enable,HIGH); // disable display outside ISR
I have same resistor on each row. red 180ohm and 100ohm on blue and red. So that doesn’t solve this mystery. And I check the code and it have the that you talked about.
When I say last row I mean the row which use the last anode to work.
So you’ve eliminated all of the options I had in mind.
Did you try swapping the 595 chips ? If the error is persistent when you change positions of the chips, it is a systematic problem (unless of course all the chips should have the same anomaly). If you have an oscilloscope you could check the PWM signal for the last row and see if the effective on-time is different compared to all the other rows.
What happens if you _remove_ “digitalWrite(__display_enable,HIGH)” ? Does the last row get even brighter ?
• the code somehow spends more time processing the last row
That is something that I didn’t tested, because I don’t know how to test that.
Changed the chip.
Last row is brighter than other row, but when I remove that line all color change to very wierd.
And now one of rows doesn’t turn on.
So if swapping the 595 chips doesn’t change anything it is also a code problem. And removing the line of code as I suggested should only change the brightness of the last row, but not the colors of all the rest. I have the feeling that code and hardware don’t interact properly. Do you have a schematic for your project ?
Controller: http://lh4.ggpht.com/_45WOFW8ZSb4/SV66O0j6HlI/AAAAAAAAFGg/WcVBQAnX1Vs/s912/LEDMatrixSchematic.png
I use different resistors as I already said.
I recorded video so you can better see what happens.
http://share.ovi.com/flash/player.aspx?media=the_banda.10477
My own code: http://pastebin.com/m14369991
That I used to test all leds work.
Aha! Now we’re getting to the poodle’s core.
In the schematic you’ve posted, some things are different to what my demo code expects.
1.)
OE (output enable) is wired to GND, which gives the “last row” error. My demo code expects OE to be wired to PB1 (Arduino digital pin #9) of an ATmega168/328 chip. And a 10k pull-up resistor should go from PB1 to +5V. This gives control over ON/OFF for the whole LED matrix and eliminates the “last row” brightness problem.
2.)
The order of the 595 chips is different:
My demo code expects this order (schematic):
spi_transfer(B00000001<<row);
spi_transfer(blue);
spi_transfer(green);
spi_transfer(red);
Your schematic + my demo code needs this:
spi_transfer(red);
spi_transfer(blue);
spi_transfer(B00000001<<row);
spi_transfer(green);
A wrong order will create “funky” colors.
When I changed code. To met order of colors like they are in hardware. It work, but the last row is still brighter…
New video: http://share.ovi.com/flash/player.aspx?media=the_banda.10478
I hope you can see those videos.
Code change:
spi_transfer(blue);
spi_transfer(green);
spi_transfer(red);
spi_transfer(B00000001<<row);
TO
spi_transfer(B00000001<<row);
spi_transfer(red);
spi_transfer(blue);
spi_transfer(green);
Yes I can see the videos. The last one is almost OK.
I’m 99.9% certain, that the remaining problem comes from not correctly wiring the OE pins of the 595 chips.
The micro controller spends about 50% of the time generating the PWM signals (only running the interrupt code, nothing else). The other 50% is free for whatever comes in the loop() function. If it happens that at the end of the ISR() function the LEDs of the last row are ON because the code decided it should be like that, and the display is not turned off by setting OE to +5V, the LEDs will stay on for the remaining 50% of CPU time, as the CPU is doing other stuff and cannot deal with the LEDs. Therefore the last row – and only the last row – will get about 50% more brightness. This is what you see. I had that problem in the beginning as well. That is why I do “<display on> – PWM – <display off>”.
I bought 10k resistor. Where I should put it?
PS: I hate CAPTCHA, because I forget to fill it everytime. So I need to write my comments twice. :D
1.) Schematic
2.) connect all OE (or G) pins together
3.) connect the whole net to PB1, so that “#define __display_enable 9″ makes sense !
4.) connect the 10k resistor from PB1 to +5V
PS: I hate SPAM –> CAPTCHA ;-)
So I need to separate OE and GROUND pins. After that connect OE pins to arduino pin 9. And but 10k resistor between arduino pin 9 and +5V. Am I right?
Yes.
Thanks man now it works like it should be. I will but video when I finnish rest of table.
Hi, i’m trying to build 8×8 RGB Matrix — 2nd arduino project
and i would put a microphone in for make that leds go with music..
You know how?
Thanks
You will definitely need an amplifier to make it work properly.
Something like this might work:
http://forum.sparkfun.com/viewtopic.php?t=11430&highlight=sound
http://sound.westhost.com/project60.htm