LED Cube 8x8x8

FeaturedContest Winner

Step 8: IO port expansion, more multiplexing

Picture of IO port expansion, more multiplexing

We gathered from the last step that an 8x8x8 LED cube requires 64+8 IO lines to operate. No AVR micro controller with a DIP package (the kind of through hole chip you can easily solder or use in a breadboard, Dual Inline Package) have that many IO lines available.

To get get the required 64 output lines needed for the LED anodes, we will create a simple multiplexer circuit. This circuit will multiplex 11 IO lines into 64 output lines.

The multiplexer is built by using a component called a latch or a flip-flop. We will call them latches from here on.

This multiplexer uses an 8 bit latch IC called 74HC574. This chip has the following pins:

  • 8 inputs (D0-7)
  • 8 outputs (Q0-7)
  • 1 "latch" pin (CP)
  • 1 output enable pin (OE)

The job of the latch is to serve as a kind of simple memory. The latch can hold 8 bits of information, and these 8 bits are represented on the output pins. Consider a latch with an LED connected to output Q0. To turn this LED on, apply V+ (1) to input D0, then pull the CP pin low (GND), then high (V+).

When the CP pin changes from low to high, the state of the input D0 is "latched" onto the output Q0, and this output stays in that state regardless of future changes in the status of input D0, until new data is loaded by pulling the CP pin low and high again.
To make a latch array that can remember the on/off state of 64 LEDs we need 8 of these latches. The inputs D0-7 of all the latches are connected together in an 8 bit bus.

To load the on/off states of all the 64 LEDs we simply do this: Load the data of the first latch onto the bus. pull the CP pin of the first latch low then high. Load the data of the second latch onto the bus. pull the CP pin of the second latch low then high. Load the data of the third latch onto the bus. pull the CP pin of the third latch low then high. Rinse and repeat.

The only problem with this setup is that we need 8 IO lines to control the CP line for each latch. The solution is to use a 74HC138. This IC has 3 input lines and 8 outputs. The input lines are used to control which of the 8 output lines that will be pulled low at any time. The rest will be high. Each out the outputs on the 74HC138 is connected to the CP pin on one of the latches.

The following pseudo-code will load the contents of a buffer array onto the latch array:

// PORT A = data bus
// PORT B = address bus (74HC138)
// char buffer[8] holds 64 bits of data for the latch array

PORTB = 0x00; // This pulls CP on latch 1 low.
for (i=0; i < 8; i++)

PORTA = buffer[i];
PORTB = i+1;


The outputs of the 74HC138 are active LOW. That means that the output that is active is pulled LOW. The latch pin (CP) on the latch is a rising edge trigger, meaning that the data is latched when it changes from LOW to HIGH. To trigger the right latch, the 74HC138 needs to stay one step ahead of the counter i. If it had been an active HIGH chip, we could write PORTB = i; You are probably thinking, what happens when the counter reaches 7, that would mean that the output on PORTB is 8 (1000 binary)on the last iteration of the for() loop. Only the first 8 bits of PORT B are connected to the 74HC138. So when port B outputs 8 or 1000 in binary, the 74HC138 reads 000 in binary, thus completing its cycle. (it started at 0). The 74HC138 now outputs the following sequence: 1 2 3 4 5 6 7 0, thus giving a change from LOW to HIGH for the current latch according to counter i.

Remove these adsRemove these ads by Signing Up
Tabur7 months ago
There's an error: "Onlye the first 8 bits..." It's the first 3
I would have thought you'd jump on the fact that we are indeed actually DEmultiplexing, and not multiplexing. Oh well, everyone knew what he meant.
Yup, I missed that typo too. Good catch.
Please send me the multiplex_theoretical.sch file. I'm having trouble while downloading it. 
My email address is-
8602366951 year ago
pls check all file ,type of all change to " .tmp "
pls help my Email:
Could anyboby help me with the multiplex_theoretical.sch and others diagram files i'm having an error when trying to download them, it downloads a .tmp file that doesn't works, can't be opened,
i will apreciate any kind of help.
my email is
Thks in advance !
Solannis2 years ago
I think I am missing something. I am new at interpreting digital schematics, so forgive me if I am misunderstanding something. In the diagram above, it appears that all the Dn data pins (D1, D2, D3, etc.) for each 574 are tied together, along with the OE pins. If that is the case, how does each individual data pin get it's data? I understand the pesudo code and what it is doing: uploading one buffer's worth of data per 574, making sure that the appropriate 574 gets its Clock CP pin lowered then raised to latch the Dn data to the corresponding flipflops and outputs (Qn) But how does each pin figure out which data bits are specifically for it?

Or am I reading the schematic wrong to begin with? Is that dark blue line just a convention that means that all LIKE pins are connected connected, such as all D1s are connected to all other D1s, all D2s are connected to all other D2s, etc., or are all those pins (D1s, D2s, D3s, D4s, etc.) REALLY on a single, common bus? Any help would be appreciated.
The thick dark blue line is a data bus, its a way of cutting down clutter in a diagram.
They are actually all different cables.. imagine a cat5 network cable, it has 8 wires inside it, but its all just 1 cable.

Although it can be confusing, these data buses normally have labels to show what each wire is.
Im going on the assumption that D0 is connected to 1D pins on all the multiplexers, D1 to 2D pins, D2 to 3D pins.. etc.

So a high on D1 will be a high on all 1D pins.
Then the data is latched into a specific 574 by toggling the clock pin of that specific chip via the 138

I hope i make sense..
i am confused still.....
does this mean to connect all the 1D pins of all the latches to the D0 pin of the ATmega.......??
Im not sure if i can explain any simplier.. but i'll try.

All the data pins of the 574's are connected together.
1D to all other 1D's, 2D to all other 2D's.. etc.

This way, you only need 8 pins on the microcontroller to send data to all chips at the same time. But only the chip with OC low will actually read the data on the rising edge of the clock signal and set its pins accordingly to that when OC goes high.

Its been a while since i've used the 74HC574N, but at least the theory of it is sound.
That does make sense. Thank you very much for the reply. It helps me to understand it a bit better.
asingh651 year ago
i am confused still.....
does this mean to connect all the 1D pins of all the latches to the D0 pin of the ATmega.......??
tboultwood12 years ago
Am I right in saying the latches or flip-flop thingies are also could shift registers? I have made a 3x3x3 LED cube before and 4x4x4 and failed. So I hesitate to make this in case 10 pound worth of leds are wasted! :L I might make it for an on going project though :P Great tutorial and great guide! Thank you
shenn1642 years ago
Can I wire the components exactly as it is on the schematic? i'm a confused with this multiplexing circuit i don,t know exactly how it works. all the wires goes through one path. please help.
aleal32 years ago
What should i do with the Output Enable pin???? i have to connectit to my microcontroller?
addhi2 years ago
Hey guys

You can just change the file from *********.tmp to **********.sch and open it in EAGLE CAD. :-)
itsgambit2 years ago
I dont know what I am going wrong but when go to download the files all I get at .tmp files and not .sch or .tar files. I was able to download the pricelist file as random_string.xls ... noob to this site... awesome instructable btw will let you know how it goes when done.
jtovar932 years ago
I'm not sure if I'm understanding correctly...

How is the 74HC574 supposed to be programmed?

Can someone please explain me?
I am confused but i would really like to make this cube, can someone explain me how the 74HC574 should be programmed, or if I am completely wrong, can someone point me in the right direction?

anhthux082 years ago
YOU CAN SEND YOUR FILES multiplex_theoretical.sch to mail
shiva191922 years ago
Hello sir, i am really impressed with you and your cube. Really i also want to try that. Iam just a beginner to this digital electronics. could u please explaine me in that STEP 8 & 9.
Hi All,

I am looking for the schematic files. Did someone managed to download them and construct the cube?
Hey !

I am newbie, whenever i click on the attached file (multiplex_theoretical.sch), it is downloaded as .tmp file further more i dnt have eagle also can anyone send me link of that software !

Regards !

Did you manage to download the file?
vijirvy2 years ago
in ic3 in1(oc) is not connected but all other ic's pin1 is connected
sfbaynate2 years ago
Hey Guys, what viewer/program is used to view these .sch files?
Eagle CAD!
Thank you!
yww3366002 years ago
hello!!! i am a chinese guy .i can not download the file :multiplex-theoretical.sch. I need the circuit diagram .Clould you send the file to me ?
Think you!!!
my e-mail :461421228! or
TechNotes3 years ago
Hey guys, I am new to this and I have a pretty dumb question. If you multiplexing 11 IO lines in to 64 anode lines, how can you still control each LED?
Im just going to matrix 4 by 4 equals sixteen then use four more io pins to matrix that to 64 io pins then just use audio transistors to run the LEDs on external power
hemmikarl3 years ago
I am working on a cube based on 8 8x8 LED matrix stacked on top of each other and toggled between with a IC called 4017 this enables me to use only 17 output pins of my micocontroller
I hope to make it usb compatable and yet still beeing able to run without a computer
hatschel3 years ago
I t means the 74HC164 instead of the ACT138
hatschel3 years ago
hey I use a similar circuit
it´s still the same but uses the shiftregister 74HC164
would it work with the software?
asdff1233 years ago
what software do you use to edit your sch files
I think eagle
pintecan3 years ago
where the scheme??
akkoe3 years ago
I was wondering what the maximum current is you can get from the 74HC574 IC's. I'm a little bit puzzled with all the figures in the datasheet, but fore sure it's not unlimited.

I seems you people use 6mA per led. is this because of limitations of the latch IC?