64pixels are enough

I love Blinkenlights. And all kinds of other blinking and flashing LED stuff. I think, it’s already a form of addiction. When I ran across an LED matrix with square pixels, I thought it would be cool to build a small animated display with it. To keep things simple, the display is attached directly to the microcontroller the “Evil-Mad-Scientist-way”.

The display performs really well, the pixels are bright and the batteries last for over two weeks running non-stop. The microcontroller has 2 k flash RAM. That’s enough for three simple animations and a couple of messages.

If you want to see the guts, then follow me to the 64pixels howto.

35 thoughts on “64pixels are enough”

1. Pingback: 64pixels are enough - Hack a Day

2. Seems like a bad idea to rely on the micro’s output pin drivers to limit the LED current. I understand it’s a hobby project so you should do what you want, but it wouldn’t pass a design review in the real world.

Like

3. Anyone care to elaborate on why the current limiting in the microcontroller is a bad idea?

As much as I love smug nay-sayers, I’d much rather learn something from this “bad idea” than accept unsubstantiated criticism into what I “know.”

Like

4. Okay, this may give you some background, why it’s supposed to be a bad idea, to drive an LED without an limiting resistor.

The matrix datasheet only states:
Forward Voltage matrix: 1.8V-2.2V and a maximum rating of
Forward Current: 25 mA. No curves.

To calculate how much current goes thru the LED (and so thru a source and a sink pin) we assume, that the LED runs with 4 mA at 1.8 V. That’s somewhat reasonable when you look at other LED datasheets. One thing to remember is, that forward current vs. forward voltage is not a straight line.

Now we take a look at the I/O pins of the microcontroller. The datesheet can be found at: http://www.atmel.com/dyn/resources/prod_documents/doc2543.pdf

It states: DC current per I/O pin: 40 mA. That should be the maximum current.
Then we take a look at the figures 106 and 107, which show the ability of an I/O pin to source and sink current.

If we insert our 4 mA from above, we get:
I/O Source current (Fig. 106): 4 mA at 2.5 V and 2.7 V Vcc
I/O Sink current (Fig. 109): 4 mA at 0.2 V and 2.7 V Vcc
== 2.5V – 0.2V = 2.3V

That means, the I/O pin sources 2.5 V, then comes the LED and at least another I/O pin sinks the current at 0.2 V. That leaves 2.3 V for the LED. More than we assumed (1.8V).

Okay, now lets use the same figures with new values. We assume a current of 15 mA thru the LED (more current, because of more voltage).

I/O Source current (Fig. 106): 15 mA at 2.1 V and 2.7 V Vcc
I/O Sink current (Fig. 109): 15 mA at 0.5 V and 2.7 V Vcc
== 2.1 V – 0.5 V = 1.7V
That look quite ok to me. Ok for the LED and ok for the micro.

As you see, the voltage, that the microcontroller delivers is tied to the current, that it sinks or sources. That means, the more current you demand, the lower the voltage. The current goes up from 4 mA to 15 mA and the voltage drops from 2.3 V to 1.7 V.

In the simplified design for the matrix there are no current limiting resistors. That means, the LEDs suck as much current as they could and as the micro delivers. If more LEDs are lit, the current rises and the voltage drops. So, the more LEDs are lit, the dimmer they get. In real, you can notice that, but you have to look at it very thorough.

Does this clear things up? Maybe I should do an extra post about that.

Like

5. Would this be programmable in-place? I would think so, but I’m not sure. The SpokePOV is pretty similar and that one is programmable, so I’d assume this should be as well.

Any thoughts?

Like

6. The pins for ISP are all used for the matrix. Furthermore, the LEDs directly attached to the micro may pose a problem to a programmer, because they will need some mAs to get the voltage up. And they might just burn down, if you attach a 5V ISP programmer.
But, you could solder a 20-pin socket to the matrix and then pop the micro out, if you want to reprogram it externally.
Or, set it up on a breadboard first.

Like

7. The pins on the 2313 of the minipov3 are also used for LEDs, but still it can be programmed in place. I guess the main difference is that the minipov uses resistors before the LEDs (very informative post on when to use resistors, thanks for that!) so it won’t burn out when programmed. The LEDs do light up somewhat when it’s being programmed.

Like

8. Awesome idea, and I’m working on a slight modification of it for my own devious uses… :D I’ll post pics, build, and proper credit on my site once it’s done.

Have you (or anyone else) had any trouble with Futurelec, though? It’s been over a week since I ordered a few of the LED matrices from them, and I haven’t seen anything except a “we received your order” email.

Like

9. Cool, I would love to see that.

Futurelec? Once I waited a couple of days. Then I wrote an email and received a very kind mail back almost instantly. They were waiting for some parts and offered to ship the parts they had already. Worked fine for me.

Like

10. Hey Alex,

i tried to flash the Attiny by myself but always getting an Error-Message while flashing the firmware..:

[…]
avrdude: ERROR: address 0x0810 out of range at line 129 of matrix.hex
avrdude: write to file ‘matrix.hex’ failed
[…]

can you tell me whats wrong with it?

Like

11. Hi Mischka,
I just learned, that the avr-gcc 3.4.6 (comes with CrossPack) packs the code much tighter as the newer gcc 4.x compiler.
The newer WinAVR 20090313 compiles the matrix.c to 2310 bytes. The old compiles it to 1958 bytes. For now I would suggest to install an older version of avr-gcc (WinAVR) and try again.
In the meantime I will try to squeeze the code a bit.
Cheers,
Alex

Like

12. Please try WinAVR-20060421-install.exe, that one comes with gcc 3.4.6.

Like

13. Hey Alex, Thanks for your reply. I am using Linux, so WinAVR would not work, but i’ll try an older version of avr-gcc.

Like

14. Alex, Mischka…

I’m getting the same error when I try to burn the hex file.

Basically, it boils down to “the file’s too big”?

I already have two versions of avrdude on my box just to accommodate the fact that I’m using my Arduino Diecimila as the programmer (FTDI, etc.), and I’d really rather not build a “spare” version of gcc.

Could I simply trim the final size down by removing some animations and/or scrolling text?

Like

15. Hi Nate,
yes, at the end it’s a “the file is too big”.
You can try to cut things down by removing some messages and/or animations.
Cheers,
Alex

Like

16. Is there anything special about a 3V CR2032 lithium battery that would make it unsuitable to power one of these?

Like

17. Hello :)

I am trying to build this with a 8×8 Led-Matrix:

It has the same witing as the one from Futurelec, but somehow i only end up with the whole matrix lit constantly. Any hints?

Thanks

saw0

Like

18. Hi saw0,

the pinout looks the same, but the LEDs of your matrix is common anode, while the one I used, was common cathode.
There is a code snippet (display_active_row) in the source that is commented out right now. Try to use that part.

Cheers,
Alex

Like

19. Hey Alex!

Thanks for pointing this out, now i also see that the wiring is different.

I uncommented the part, It works flawlessly now.

Thanks for this nice Blinky, my girlfriend loves it :)

Just another question: I don’t quite understand how to make own animations:

0x18, // ___XX___
0x3C, // __XXXX__
0x7E, // _XXXXXX_
0xDB, // X_XXXX_X

how can i translate the “0x##” part so i know which pixel i actually lights?

saw0

Like

20. Hi saw0,
0x## is the hex notation.
As an example: 0x18 is one byte in hex. In bits it looks like this: 0001 1000, so first 4 digits is the 1, that last 4 is the 8. So that lights up the two LEDs in the middle.
Cheers,
Alex

Like

21. Thank you so much :)

I found a Conversion table in the net.

Greetings

saw0

Like

22. Simplicity rules!

I like this small thing. You can compile with current AVR-GCC instalations by using the compiler option
-fno-inline-small-functions

In the Makefile:

COMPILE = avr-gcc -Wall -Os -fno-inline-small-functions -DF_CPU=\$(CLOCK) -mmcu=\$(DEVICE)

Like

23. Hi Alex,
great idea and look nice, uuummm how can I get full text size? (using all 8 row instead of 5), i’ve try to edit font.h but without luck, can you help me. i just want to displaying 2 words, but at full sized font. it is possible?

Like

24. Hi Dani,
all characters in font.h are at max 3 pixels wide. Every byte stands for a single column, the last byte stands for the length of the character, e.g. if you want to light up the up most 2 pixels, that would be 0x03, or binary “0000 0011”. That way you can design you own font. Making the font wider would be a bit more complex.

Like

25. Hi Alex, this is an awesome project. I want to build this project myself but before that, can you please give some detail about fuse bit’s setting of Attiny2313 for this project. Thanks!

Like

26. Hi G’duino,
take a look at the Makefile, included in the zip, at the end of the howto article.

Like