LED display Atmega - Running out of output pins
So is there a way?


At first I though not but if the displays can withstand reverse polarity on the X and Y pins the scheme below might work.



Figure 1. Swapping rows and columns on two of the displays may permit controll of four displays with only three ports.

This description assumes that the displays are arranged in rows and columns and that the LEDs are lit by pullig a row HIGH and a column LOW.


To light the first matrix set each PORT0 row HIGH in turn and pull the relevant bits of PORT1 LOW to light the required LEDs in that row. Rows that are not active should be tri-stated to open and not pull LOW.
To light the second matrix set each row LOW in turn and set bits of PORT 1 HIGH to turn on the required LEDs in that row. Again, unused rows should be tri-stated to open.
The third and fourth matrix are controlled in the same way by PORT0 and PORT2.


So far we've used three ports and saved two.

The four-digit displays can be treated as one by connecting the eight segments to PORT0 and the 4 + 4 digit select lines to PORT3. Four ports used.

If you now connect matrix 5 in reverse (as we did with matrix 2 and 4) between PORT0 and PORT3 you would be finished. Still only four ports used.

This technique is known as Charlieplexing.


  It's clever, but will it really work? The 8x8 led matrix has 64 LED. to light it up, it needs multiplexing anyway. when connected in reverse, won't doing multiplexing on the first led display accidentally turn on the second one?




Figure 2. Sample of switching on top left LED of DISP1. Note tri-state switches on PORT0 and PORT1.



Figure 3. Charlieplexing sneak paths.

Figure 3 shows a potential problem with sneak paths through multiple LEDs in the other display. The sneak path has three LEDs in series (shown in orange) but the LED shown green will limit the voltage so that the others don't light. With a large number of parallel displays the leakage current may become significant.

Note that to turn on the LED shown in Figure 2 the required outputs will be

PORT0    1xxx xxxx
PORT1    0xxx xxxx


where 'x' is tri-state open/disabled.