Step 8: 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.

<p><a href="http://www.baatkar.com" rel="nofollow">For how to guides and software tutorial visit this</a></p>
<p><a href="http://www.baatkar.com" rel="nofollow">Great Article I Appreciate Your Work</a>. </p><p>Thanks</p>
<p>where are all the comments</p>
<p>I went over this website and I believe you have a lot of wonderful information, saved to my bookmarks<br><a href="http://memyfriends.com/how-to-get-a-hot-girlfriend-if-youre-ugly/" rel="nofollow">can i get a hot girl if i'm ugly</a></p>
<p>Is it just me, or did all the comments disappear?</p>
<h3><a href="http://nasirilyas.com" rel="nofollow">nasir ilyas</a></h3><p>Thanks for sharing this quality information with us. I really enjoyed <br> reading. Will surely going to share this URL with my friends.</p>
<p>This is a great article thanks for sharing this informative information. <br> I will visit your blog regularly for some latest post. I will visit <br>your blog regularly for Some latest post. <br><a href="http://j.mp/AddSite" rel="nofollow">Submit URL</a></p>
<p>This one is good. keep up the good work!..<br> <br><a href="https://www.youtube.com/watch?v=WXPalR1Ljvs" rel="nofollow">Rich Jerk</a></p>
<br> This is such a <br> great resource that you are providing and you give it away for free. I love <br> seeing blog that understand the value of providing a quality resource for <br> free. <br><p><a href="http://www.nagmauritius.org/how-to-get-a-woman-hooked-on-you/" rel="nofollow">nagmauritius.org/how-to-get-a-woman-hooked-on-you/</a></p>
<p>i love reading this article so beautiful!!great job!<br> <br><a href="http://movietubenow.weebly.com/" rel="nofollow">movie tube now</a></p>
<p>These are some great tools that i definitely use for SEO work. This is a great list to use in the future.. <br><a href="http://www.aconsult.fr/pascher.asp" rel="nofollow">Canada Goose Manteau Solde</a></p>
<br> Great <br> Article it its really informative and innovative keep us posted with new <br> updates. its was really valuable. thanks a lot. <br> <br> <a href="http://www.entretien-menager-genial.ca" rel="nofollow">menage apres construction prix</a> <br>
<br> I read <br> that Post and got it fine and informative. Please share more like that... <br> <br>menage apres construction prix <br>
<p>Thank you for such a well written article. <br>It&rsquo;s full of insightful information and entertaining descriptions. Your <br> point of view is the best among many.<br><a href="https://www.youtube.com/watch?v=_pHN8PeeYqU" rel="nofollow">Affilojetpack 2 Review</a></p><br>
<p>hai guys I want to know how much power and amp give for cube and I am using arduino so arduino hold 1.5 amp 5v and connect to driver board or I give power to driver board separately and arduino separately and how much I want give can u give me detail</p>
<p>Hello i have built this cube but i am having problems. i upload the test code and everything works but after i uploar the second code as well as the firmware nothing happens</p>
<br> This is actually <br> the kind of information I have been trying to find. Thank you for writing <br> this information. <br> <br> <a href="http://womeninneuroscience.org/sleep/side-effects-kavinace.html" rel="nofollow">more</a> <br>
<p>I will make it</p>
<p>Thanks for taking the time to discuss this, I feel strongly that love <br>and read more on this topic. If possible, such as gain knowledge, would <br>you mind updating your blog with additional information? It is very <br>useful for me.<br><a href="https://www.youtube.com/watch?v=NQgksA_SL7Y" rel="nofollow">Fat Diminisher</a></p><br>
<p>Your website is really cool and this is a great inspiring article. Thank you so much. <br><a href="https://www.youtube.com/watch?v=tLRUy_wPIro" rel="nofollow">Video Vibe Pro Review</a></p>
<p>I am using arduino mega as isp to program or usb pic or if u any software for led programming that is also good </p>
I'm good to go now found good files on pyroelectro.com by thepyroelectro www.pyroelectro.com/projects/8x8x8_led_cube/arduino_8x8x8_cube.pde
can you tell me how to copy and paste animations into the my main sketch from other sketches? So I can add more animations. what section sketch to copy and where to place it. thanks
<br> Fantastic blog you <br> have here. You&rsquo;ll discover me looking at your stuff often. Saved! <br> <br> <a href="http://www.entretien-menager-genial.ca" rel="nofollow">menage apres construction prix</a> <br>
<p>hi , i have made CRR's led cube but something very strange is happening</p><p><iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/YZucW88VQr0" width="500"></iframe></p><p>there are led lighting that must not light. I have change emmitter with collector , i have use only one 2n222 as <a href="http://www.instructables.com/member/SuperTech-IT/" rel="nofollow">uperTech-IT</a> says but nonthing good.</p>
<p>I noticed you got yours up and running. Congrats. I see you went the 2 transistor rout in the end, but that's OK, it's just more parts than needed.<br>My boards are a lot more compact than yours, and allow Arduino's ATmega328p or the ATmega32/32A/32L processors, but the end result is pretty much the same. LOL. Here you can also see one of my completed single colour cubes beside one of my RGB cubes.<br></p>
2N2222 transistor have 600ma current max on colector and one led need 0.015ma mutil by 64 led each layer equal ~1A. Therefore you need at leat 2 2N2222 transistor
<p>More precisely, my design uses single 2N2222 for the layers - the whole cube with all LEDs lit draws under 700mA. Anyways, if you still have not worked this out, go to www.TheLEDCube.com and download my source code for your processor which contains a POWER ON SELF TEST. Video the POST and put the video up here and I will analyze it and point you to pretty much exactly what's wrong right off the bat unless there are multiple shorts / bad connections.</p>
<p>Hey, can u uploade a bit more detailed description of the power supply.</p><p>I cannot figure out how to solder the pieces</p>
<p>Your best bet is to simply get a 5V 2A plug-in power supply.</p><p>These are cheap and plentiful on ebay.</p>
<p>What have you used, atmega or arduino? </p>
<p>i use atmega</p>
<p>It worked flawlessly buddy. it is such a great feeling achieving that task</p>
<p>The Arduino is also ATmega in that the processor is an ATmega328P.</p><p>Most people prefer the ATmega32/32A/32L for this project though.</p>
<p>Finally, It worked flawlessly. Now I want to go to the next level and use atmega32. Problem is to get the crystal, I'll have to import it</p>
<p>and of course i have place 8 pull up resistors on collectors ,6.2k</p>
<p>finally it works! there were many short circuits and tow transistor had electrik leak</p>
<p>Glad you got it all up and running! Hope to see a video of your cube in action!</p>
<p>Is there any program to control led cube and make coding easy ,just clicking on leds we want to gets on with the order we want?</p>
wow I'm blown away. I built the jameco 8x8 cube pcb version. their sample code works great but I sure would like more code that will work with this kit. I'm glad I made the cube large with 25mm spacing thanks for the advice.
I built the Jameco 8x8x8 cube PCB version. I need better code than the sample file. Please help.
<br> I found your this <br> post while searching for information about blog-related research ... It's a <br> good post .. keep posting and updating information. <br> <br> <a href="https://www.usheat.com/Thermocouple" rel="nofollow">usheat.com</a> <br>
<p>I am not using rs232 ic just using atmega32 and 74hc574and 74hc138ic just using basic module I don want confuse I want program the atmega working alone </p>
<p>give me link </p>
<p>Hai guys I need help with complete code and this is my first project I am done everything I need only code I am using 74hc574 ic I want code based on that and another thing I am chef I not familiar with c programming I am doing project in hobbies because I love electronics pls help me with that ,that's greatfull for me</p>
<p>Help needed!</p><p>I managed to put everything together and now I am having problems with programming. I have little experience in this, so I don't what's wrong:</p><p>I have (a copy of) Arduino Uno, i programmed it as an ISP so that i would able to program the cube's Atmega32. </p><p>I wrote: </p><p>avrdude -c avrisp -P COM3 -p m32 -U lfuse:w:0b11101111:m -F</p><p>(I used -F to get any result, because otherwise all i got was: </p><p>avrdude: Device signature = 0x000000</p><p>avrdude: Yikes! Invalid device signature.)</p><p>And i get a verification error (see screenshot). If I do anything afterwards, all i get is this: avrdude: stk500_cmd(): programmer is out of sync</p><p>After reconnecting Arduino usb, i get the same result (verification error and then out of sync error). </p><p>Also, it is unclear to me whether the programming header's jumper should be used. If I disconnect it, the avrdude displays out of sync error immediately. If i do use the jumper, the cube lights up seemingly randomly and after some time pretty much all of the LEDs are lit up. Is it a soldering problem or is it supposed to happen?</p>
<p>I suggest getting an USBASP or USBTiny off ebay. They are typically $2 to $5.</p><p>The other option is to program your arduino to control the cube itself.</p>
Thanks, i figured that would be necessary. Would i have to make any changes to the board to use Arduino with it? Or should i just wait for the programmer to arrive?

About This Instructable


3,522 favorites


Bio: I like microcontrollers and LEDs :D
More by chr: Reverse Engineering: RGB LED Bulb with IR remote Reverse engineering: USB controlled home automation hack LED Cube 8x8x8
Add instructable to: