Arduino Forum

Using Arduino => General Electronics => Topic started by: plasmaninjaa on Dec 08, 2012, 10:07 am

Title: LED matrix, How to use fewer pins?
Post by: plasmaninjaa on Dec 08, 2012, 10:07 am
Hi, I am planning on making a display with a few 8x8 (or any other size, doesnt really matter) led matrixes. Are there any tricks to use less pins? Does anyone know of a good tutorial on how to work with these displays? I need to use the least amount of pins as possible.

Thanks for the help :)
Title: Re: LED matrix, How to use fewer pins?
Post by: dc42 on Dec 08, 2012, 10:30 am
An 8x8 LED matrix has 8 anode lines and 8 cathode lines. I'll call the cathode lines columns and the anode lines rows. One way of driving it is to pull one of the column lines low, and pull the row lines corresponding to the LEDs you want lit in the column high. After a while, switch to the next cathode line and repeat. Do this fast enough and the eye can't see any flickering.

You need to use transistors or other drivers on the column lines, because you will be lighting up to 8 LEDs in a column at a time. You can drive the rows from Arduino pins, each one through a series resistor, if 20mA is enough for the LEDs.

So in its simplest form, you need 16 pins (8 for the columns and 8 for the rows). To reduce this, first use a demultiplexer on the column lines. A 3-to-8 demultiplexer such as the 74HC238 lets you select which of the 8 column lines you drive using just 3 pins instead of 8. So that's 11 pins now.

To reduce the pin count further, use an 8-bit shift register to drive the row lines. You need 3 pins to drive the shift register. So that's 6 pins in total.

To drive multiple 8x8 displays, you can connect the column lines in parallel. You can also daisy-chain the shift registers. So, with 6 pins, you can drive any (reasonable) number of 8x8 displays.
Title: Re: LED matrix, How to use fewer pins?
Post by: Docedison on Dec 08, 2012, 12:43 pm
What does Google say? He (or She) has far more information than the sum of all the Arduino users... Try there First and then bring the questions you have after your search here for more 'selective' answers. Your question is open ended and until it is better bound, unanswerable as there are too many variables... including but not limited to "How Big is this thing" which you declined to accurately state.
I Quote:
Quote
display with a few 8x8 (or any other size, doesnt really matter) led matrixes.
.
Size Does Matter... A Lot... so start looking at what has been done and pick your 'ultimate project first... then come ask how to make it. You'll get much better answers.

Bob
Title: Re: LED matrix, How to use fewer pins?
Post by: Grumpy_Mike on Dec 08, 2012, 11:36 pm
Quote
Are there any tricks to use less pins?

Yes lots.
When you say pins I am assuming you mean arduino I/O pins. Port expanders are easy to get more outputs as are shift registers. You can also get chips that will do the matrix scanning for you using only 5 pins. Or even charlyplexing chips.
But if you don't say what you want we can't tell you what to use.
Title: Re: LED matrix, How to use fewer pins?
Post by: CrossRoads on Dec 09, 2012, 01:27 am
Drive each 8x8 with a MAX7219 and daisy chain them. Hard to get fewer pins than that: SCK, MOSI, SS (MISO committed but not used).
Title: Re: LED matrix, How to use fewer pins?
Post by: Boffin1 on Dec 09, 2012, 09:48 pm
Do you use the LedControl library with the MAX7219s  Crossroads ?
Title: Re: LED matrix, How to use fewer pins?
Post by: CrossRoads on Dec 09, 2012, 10:57 pm
I do not.
I use SPI.transfer() for everything, nice & fast. I have not used the equivalent of shiftout(), which is what LED library does, in over 2 years now.
A lot of times I use direct port manipulation even to control the SS line.

Couple of transfers in void setup to initialize it (them),
then blink without delay kind of routine to make updates.

Title: Re: LED matrix, How to use fewer pins?
Post by: Boffin1 on Dec 09, 2012, 11:39 pm
I am thinking of using SPI more,  I am busy reading up on multiplexing, and I think if I want to get the next data into the shift registers as quick as possible ready for the next row ?
Title: Re: LED matrix, How to use fewer pins?
Post by: CrossRoads on Dec 10, 2012, 12:39 am
SPI will definetely get it there faster and take less clock cycles of processing to do it.
Make sure to put decoupling cap on each shift register.