2 July 2011

The Charlie Cube Mark II: 4x4x4

Project Features
  • Minimal hardware
  • Wiring more complex than standard led cubes
  • LED duty cycle 1/8

Update: There is a schematic and part list available here.
WARNING: Do not build this cube unless you know what you are doing! It uses minimal hardware but is difficult to understand.

There is a new design which is much easier to build with a very low part count.

When I had finished my first charlieplexed LED cube (3x3x3) I wondered whether my next project should be a 4x4x4 cube. But at the time I thought it wasn't worth the effort. After all, I had just shown that a charlieplexed cube is possible and that it can be done with reasonable effort.

The 4x4x4 would of course have 64 LEDs, which would mean quite a lot of soldering. And since I would definitely want to use bright wide-angle LEDs, it wouldn't come cheap.

But the idea never really went away and when I found a good offer for a set of 100 suitable blue LEDs I simply couldn't resist.

Component selection
My 3x3x3 cube had been built with standard low cost 3mm LEDs, just because I had them already. The result was acceptable, but for this project I wanted to use bright LEDs with a wide angle beam so that the cube could be watched from various angles.
I found these interesting LEDs, which are no-name, but the data given is 150 mcd intensity at a viewing angle of 170 degrees. The viewing angle is achieved because the LEDs have a flat top instead of the normal lense shape. The LEDs produce blue light, but the LED body is water clear.

As for the controller, I couldn't use an 8-pin version, because I needed more ports. So I went for a 14-pin Atmel AVR ATtiny24, which was somewhere amongst my collection of left-overs. The tiny24 has only got 2kBytes of program memory, but there are pin and software compatible versions with more memory.

To get a brighter display, this time I went for a 1/8 duty cycle for the LEDs, so I had to activate up to 8 LEDs at a time. The controller I/O ports can't drive the necessary amount of current, so I used transistors as drivers, as in my very first post.

And that is about all the hardware I used.

For a conventional multiplexing scheme driving 64 LEDs, you would need 16 I/O ports (8 rows, 8 columns) and you would also need 8 drivers for your column ports. So apart from the number of ports, everything is the same.

In a conventional scheme you could trade ports for transistors by using a 16x4 matrix and therefor using only 4 drivers. But you then would need 20 I/O ports.

The charlieplexed variety of the cube only needs 9 I/O ports.

LED Matrix Structure
Similar to my post about charlieplexing, I would like to explain my systematic approach to the construction of the LED structure. It is important to use a regular structure, because it makes programming easier.

To start with, I did some math. I wanted to control 64 LEDs, so I needed 9 I/O lines: 8 x 9= 72.
A regular charlieplexed matrix looks like this - the LEDs are represented by blue dots. Bear in mind that column1 and row1 are controlled by the same port.

The matrix gets warped to remove the blank positions.

The last line of the matrix gets removed, because we only need 64 LEDs.

Now we trim this to a structure 4 LEDs high.
Finally we assign the 4x16 structure to units of 4x4. They correspond to the "slices" of the cube.

There are some useful properties in this structure. The two LED groups in each level are not connected. There are 8 groups (not 9), meaning we need only 8 transistors to drive them. All groups contain 8 LEDs in the same geometric pattern (2x4), so only one template is needed.

Building the Cube
There are loads of instructions on the net, how to build an LED cube. So I won't go into detail - only when it concerns the charlieplexed 4x4x4 version.

First I made 8 LED groups in a 2x4 configuration with common anodes.

The first two groups were soldered to a PCB.

On top came the next two groups. Notice the diagonal wires - just as in the structure diagram.

And another layer.

 Final layer - diagonal connections still open.

Now all columns are connected.

The same image, but with cathodes coloured.
Notice how the cube consists of two completely unconnected halves.

Each LED group needs its own anode connection, going directly down to the PCB (here before trimming for improved visibility).

The columns get connected.

The transistors (anode drivers) and the IC socket get added.


Not much. There are the driving transistors. Since I wanted to make this a brighter cube than the first one, I decided to light the LEDs in each group simultaneously. So I needed transistors on the common anode. This is much like in my first post, but with more ports.

Other than that, there is just the controller, an ATtiny24.

Software Structure
On the lowest level, there is a hardware initialisation routine. It sets the I/O ports and then initialises CPU clock and a counter to trigger interrupt requests every millisecond.

There is an interrupt routine, which does nothing but transfer pre-calculated values to the port registers and implement a software timer.

The main routine sets the desired LED bits in an 8-byte array and then invokes a routine, which maps the bits of this array to port values.

To generate interesting patterns in an economic way, there are some pattern generation routines, like "set led", "clear all" or a "set column".

Finally, there are routines to generate a specific delay, in order to control the display timing of the patterns.

Possible Extensions
As mentioned earlier, I only had the ATtiny24 at hand. There are versions of this chip with more memory (ATtiny44, ATtiny84). Using one of them would make it possible to implement more patterns.

Sometimes you would like to create the same pattern in several directions (X,Y,Z). So it would be useful to be able to create the pattern and then rotate it to a different orientation. This can be done simply by swapping and negating coordinates. I implemented such an algorithm, but did not use it due to space constraints.

The controller has a few unused ports left. They could be used for other I/O, like a serial interface or for buttons. This way some kind of interactivity could be added.

The Source
If you like this project or just want to get some inspiration for your own project, download the source code here. It is written for AVR gcc under AVR Studio 4.

Update: There is a schematic available here.


  1. Good work!!! I'm wondering if it would be possible to implement the game of life around the surface of the cube... http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life

  2. Do you have a part number for the LEDs? Digikey maybe?

  3. Unfortunately I don't have a part number. I bought them for very little money through an ebay dealer from china.

  4. You are truly masterful! Yours is the most minimalistic LED cube build I've ever seen. Definitely considering building one myself.

    Thanks a lot for the fabulous post!

  5. Thanks László Monda, you are too kind. I am just too lazy to build anything more complex. :-)

  6. I do not know how to have a file. hex on who can send mail for me. promises999times@yahoo.com mail is to thank my many

  7. please if you can send a to my email ur diagram of the circuit di_sc@hotmail.es please im from sudamerica and i like ur project

  8. Hm, a schematic as such isn't much help for such a 3D structure. I could draw a schematic, but it would look very much like the one for my charlieplexed matrix (April 2009), but with more rows and columns.

    This is why I tried to explain how to transform a 2D / 8x9 charlieplexed matrix into a 4x4x4 cube.

    Perhaps it would help you to start with a 2D matrix or the 3x3x3 cube as a first step?

  9. Great little project!

    Question: why no current limiting resistors, eg. 270R, like your other clarlieplex projects? Is it because of 1:8 duty cycle and max current from cells or microcontroller?



  10. Thanks Paul.

    You are absolutely right. The current through the LEDs gets limited by the controller ports. And the 1:8 duty cycle means that you can actually drive higher currents with no problems.

  11. que buen proyecto... pero tengo una pregunta, que tipo de IC utilizaron, podria usarse un lm324? gracias, ojala me respondan pronto

    1. Well no, it is not a LM324 but a microcontroller ATtiny24.

      Read here:




    1. I am sorry, but there really is no schematics. I have shown the driver circuit in the section schematics. Of course I am using nine drivers, not three.

      There is nothing else.

      I don't know how to draw a 2D schematic for the LED cube itself. It is a very complex structure and I tried to explain how to create it by using the simplified matrix graphics. If you have problems to understand that, maybe you should start with a 2D charlieplexed matrix and then try the 3x3x3 cube first. (See my corresponding posts).

  14. The components are: 64 led Bright lights, 8 1k ohms and Attiny24 what value of the 8 transistor??

    1. That component list is correct.

      The transistors are BC337-40, but I think almost any small-signal NPN transistor will do.

    2. BC547,548,147,148, SL100 for more current load

  15. Hello Tom,

    this is perfect, great work. I'm sitting here and started to implement this on my Arduino Uno (ATmega328).

    One Question: you say 1/8 duty cycle and up to 8 Leds on any given time for brightness. I thought that Charlieplex only works if only one LED is on a time so that would mean 1/64 duty cycle. I guess you have identitfied groups of 8 which don't influence each other. I have problems, identifying those groups. Can you help please?


    1. Excellent! It's people like you I really write this blog for! You use it to build your own ideas on top. Great!

      Yes, there is a common misconception that charlieplexing means low duty cycle. But this is not true. If you accept the fact that you have to use driver transistors, it works almost like normal multiplexing.

      Have a look up at the schematic under the headline "Schematics" in this post.

      Imagine C1 was high. Then LED4 and LED7 can be activated by setting C2 and C3 low at the same time. Or you can activate only one of them or none. So you have all possible options.

      It works the same with C2 high. Then you can activate LED2 and LED8 independently from each other if you set C1/C3 low.

      It works the same for C3 of course.

      You end up with a 1/3 duty cycle with those 6 LEDs, while most people will tell you that you can only achieve 1/6.

      In general, if you set one output high, each other port in a charlieplexed matrix can be set low and will then activate one LED. But you do need a non-inverting driver circuit on the "high" port.

      I think the reason for the duty cycle misconception is that charlieplexing is meant to be hardware-effective. And you are most effective if you only activate one LED at a time, because then you don't need the driving transistors.

      Hope that helps! And perhaps you might want to read my first post ever, which discusses this exact issue (April 2009 / Musings on Charlieplexing).

    2. Hello Tom

      Thanks for the hints. I build the cube by now and hooked up my Arduino. First test shows that I can light up every LED by itself so my soldering and the transistors seem to work.. Now the fun can start designing some pattern engine..

      Thanks again for the inspiration!

      My daughters think I'm a hero;-)


    3. Great! If you put the result somewhere on the net, please come back and leave a link here.

    4. Hello Tom,

      sure, will do. So far my Arduino can rotate any patterns x,y and z in 90° steps. It's pretty much fun so far.

      BTW, what might confuse your readers here is the fact that the 8 transistors need to go on the "green" lines on your matrix drawings which are the horizontal lines. In your schematic, they are on the vertical lines which gives the impression that the tarnsistors should go on the "red" lines. If the schematic would be rotated to the left by 90° it would be more obvious.


  16. you sell? I live in Brazil and I want to buy.

    1. No, I don't. This is just my hobby.

  17. I really like the use of Charlie-Plexing to make the cube. I understand and have used the concept, but combining the wire bending and position of Anode/Cathode on the LED's it gets complicated. I understand your cube is assembled, but if possible could you include a zoomed in photo/diagram of the 8 LED segment with Anode/Cathode labeled and also which pins get attached to where. Thanks!

    1. James,

      perhaps my description of this project is a bit brief. One reason is that it is a kind of 'sequel' to my earlier posts "musings on charlieplexing" and the 'charlie cube' (3x3x3). It might help you reading them.

      But here is some additional info. The LED segments/groups are connected by their anodes. So you insert the 8 LEDs into the wooden template and bend the anodes by 90°. The anodes are connected in a ring structure.

      That is the easy part...

      To understand how the cathodes are connected, have another look at the grid drawings that I made. Specifically the last drawing should tell you what to do.

      The blue dots symbolise the LEDs. The green lines are the anodes of those LEDs. If you look closely (click on the image), you will find that each green line connects 8 LEDs - the segments.

      The red lines are the cathodes. The black squares mark the 4 'slices' of the cube.

      As you can see, the two middle slices are fairly normal, i.e. the columns are connected just like in a normal LED cube. This is a good thing, because it makes soldering easier.

      So first you solder e.g. the two bottom segments on the PCB next to each other. Then you solder the two next groups on top by connecting the anodes of the stacked LEDs from the two middle slices.

      On the two outer slices you will notice, that there is another column that is connected conventionally (i.e. all 4 LEDs of the back column are connected by their cathodes).

      And finally, the drawing shows you, how the other three columns are wired. Note that you end up with five columns on the two outer slices.

      All segments are connected to their respective transistor drivers through vertical wires that I hid in the middle of the cube.

      Hope that helps!

    2. James,
      I added a modified version of the cube's side view were the columns/cathodes are coloured in red, just like in the drawing.

      I know, the photos are hard to understand, because the wires seem to blend into each other.

  18. please show the back picture of the complete PCB board.

  19. Potrebbe passare lo schema generale del circuito?

    1. L'integrato e i componenti che usa, quali sarebbero, a parte i led??

  20. The components are:

    64 LED, blue, ultrabright, wide angle
    8 1k ohms
    1 ATtiny24
    8 BC337-40

  21. Replies
    1. I haven't got a schematic. But I had so many requests that I think I will have to draw one.

      The problem is though, that it will be very difficult to get the 3D structure on a 2D schematic. This is why I tried to explain how I developed the circuit...

  22. Hi, Tom. I have a question. Reading your blog is very helpful for me. I am currently working with development of LED cubes. Carefully analyzing your schematic, it seems that in if I wan to turn on one LED in a group, there would be another LED that will be turned on. For example, if TR0(anode of lowest group in Left Half Cube) is HIGH and PA3(Cathode of first LED in the said group), LED1 will Light ON. However, LED3 of the highest group in Left Half Cube will also Light On since the anode of this group is TR3 and the cathode of LED3 in this group is PA0.

    My question is how can I make it possible for human eye to see only one LED beng turned on?

    1. Hi Joseph,
      I think you should take another look at the transistor drivers.

      Without them, everything might be a bit clearer. Then, if PA0 is HIGH and PA3 is LOW, LED1 will be ON as in your example. But _NOT_ LED3 in the highest group, because it is a diode. And it is the wrong way round.

      The transistor stage does nothing else but increase the driver strength of the HIGH signal. Feed it with Hi-Z/Tristate and it does nothing. Feed it with LOW and it does nothing either.

    2. Thank you very much Tom. I'am almost finish now in my LEDCube Module. Thank you very much for this post, this serves as my major reference. In addition to your design, I have added PNP Transistors on ports going to cathodes. Well, this gives protection for those who will use sensitive microcontrollers. Furthermore, I can still maintain 1/64 duty cycle and 9 ports usage since I can still play around with tri-state. If time permits, I can post a link of the schematic I made and the finished project.

    3. Hey Joseph, sounds good. But are you aware, that you can actually use a 1/9th duty cycle? With one common anode activated, you can pull any/all of your cathodes "low" at the same time. So you can activate a whole group in on go.

    4. Thanks,Tom. Yes, I actually did it last night. Now, for LEDs to meet their efficiency, I had isolated microcontrollers 5V supply and gave a 9V supply for LEDs to consume. This method makes me worry free, my microcontroller do its switching job, and LEDs are free to consume 9V (with smiling bright light).

    5. That sounds got Joseph. Well done!

  23. wait so the only point of the bent wires (bent cathodes) on each layer is to connect them to the next layers cathode? and so on and so forth? but then wouldn't all of the lights turn on if all of the cathodes are turned on at once? or vise versa? if all of the anodes are turned on and then if you apply power to the cathodes then they will all turn on at once? im so confused lol

    1. Did you also look at the schematic? It is at http://tomscircuits.blogspot.de/2012/10/introduction-when-i-wrote-my-post-on-my.html

      Perhaps it helps a bit.

      What we do here is that we set one port to high (cycling through all ports) and then set the other ports to Z or low depending on which LEDs should light up.

      You might want to read up on using charlieplexing in a normal 2D matrix.

  24. Good Day Tom. I would like to thank you again for this very helpful post. Here is the video of my LED Cube. http://youtu.be/tFsdiZ0r4Zs

  25. Joseph, great job! Thanks for sharing this. I absolutely love the patterns that you created, especially the diagonal wave and the "bird". I might have to steal that. ;-)

    1. No problem. It's all ours. :D

    2. Good day tom, I know this question is out of topic in this thread but I am unease knowing the fact that I received a Matched Third Party Content notice in my video, probably because of my background music. Even though I acknowledge it in my video and in the information of my video. How did you put your background music in your video avoiding the copyright notice?

    3. Hi Joseph, no problem.

      Actually, I do have this problem. So far I have done a couple of things. With one video, I have changed the pitch/speed of the song to "chipmunk" style (charlieplexed matrix). In one video, I just cut out one part and looped it a couple of times (Nightrider Light). This seems to have fooled the detection algorithm.

      In one case (Cube 3x3x3) I used free music from www.freesound.org .

      They did get me with the 4x4x4 cube. So far I see no negative effect. The only point beeing that statistics are not public anymore. And there is a link to the artist's channel - fair enough.

      I am considering to change the audio, perhaps to either free music or something with the copyright exceeded (Händel?, Bach?... :-)). It will be interesting to see if that has any influence on the viewing figures.

  26. transistor no pls

    1. Check out the update in http://tomscircuits.blogspot.de/2012_10_01_archive.html

  27. HOW DO YOU PROGRAM THE ATTIN24?? I built everything but the chip is my only obstacle.the cube and its corresponding circuit is exactly how your schematic is. please help me figure out how to program the attiny :( all i need to know is what pins on the ATTiny24 correspond with the pins on my arduino :(

  28. *Arduino Uno Atmega 328

    1. Hi there. I am not sure that I know how much info you need.

      First of all, an Arduino is relatively comfortable in that respect (at a price). It comes preprogrammed with a bootloader so that it can receive a new firmware via serial interface. Plus there is an integrated USB-to-serial chip so that you can program it through USB.

      A normal ATTiny24 hasn't got any of that. It gets programmed via a proprietary interface ("in system programming" = ISP). So you need a ISP programmer.

      There are various alternatives available. If you own an Arduino, there is a sketch available, which lets the Arduino act as such a programmer.

      Find out more here:

      You have to connect the ATTiny24 pins: GND (pin 14)), VCC (pin 1), RESET (pin 4), MISO (pin 8), MOSI (pin 7) and SCK (pin 9).

  29. Thank you so much for the info :) i will let you know how it goes :) I hope to finish the cube tonight! cant wait!

  30. La programación y creación de patrones es AVR gcc, ok, como se le hace para que el código compilado, se pase al ATTINY24?? que mas necesitas de hw conectado a la computadora y mediante qué puerto usb/com/serial/paralelo??

    1. You need a piece of hardware called an ISP programmer. The documentation of this programmer should tell you what to do. Also, have a look at the ATTinys data sheet. And consider to build the simpler cube that I designed with the inexperienced in mind.

      I wrote a review / description on a very cheap programmer that you can get from China for a few Euros.


  31. Hi Mr Tom.
    I appreciated so much your job that I decided to share with you my happiness.
    It is unusual to be so accurate, simple and effective as you are. I'm afraid you don't have ads to click on to revenue a bit your efforts.
    Best Regards
    Lucio S.

  32. Hi Lucio,

    thank you for your very nice comment. I am glad you like my blog.

    Don't worry about ads. I only write this blog because it is fun and because I learned a lot through other people's sites. So I want to give something back.

    But of course any positive comment like yours is encouragement for me to keep going. After all, I am only human... :-)

  33. This comment has been removed by the author.

  34. Hi Tom F. I have a doubt that this picture is the LED cathode connected together (common cathode)

    ; However, this picture is common anode


    My school special reports memoir work, I really like your article.

    1. Hi there,

      well, it is a bit confusing. In the charlieplexed cube I do use a common anode (the ...s1600/Group.png schematic). Each group's common anode is driven by one transistor.

      The first picture you are referring to (.....s1600/IMG_1126_crop.JPG) belongs to a different project. This is not a charlieplexed, but the "simple LED cube". And this does use the common cathode.

  35. Thank you,Tom F.

    therefore charlieplexed cube is common anode,I can follow the picture To work,


    However, I can not find This IC:ATtiny24 ; Whether other IC Use.

    My school has, thematic Make,I really like your article

    I come from TAIWAN on some translations do not understand English, please forgive me

  36. Hi Tom, greate cube! I making one from your site. I have a question, qould you make a photo of the board? I mean, from the bottom view, that i could see the connections. There is a photo, but only with the leds soldiered. That could help me a lot, because im a bit confused.
    Take care, and greetings from Poland! :)

    1. And greetings to Poland from Germany. Have you actually started to make the cube? Because if you haven't, I'd recommend to you to make the "simple cube", one of my other projects. It is much easier to build.

      I can take a photo, but you have to give me a few days.

      Also if you really want to build this one, did you also look at the "update" post? There is a schematic.

  37. Hi, Im from Mexico City, tnks so much, for share, I was doing the project, I just have a doubt, about the code, I just get an AVR programer, for ATTiny24, but, im not sure if eXtreme burner AVR can program c source, cause I try with a code HEX that u post in other page see... pls help me... beforehand ty so much

    1. Manu, don't confuse the firmware with the source code.

      The source code can be written in C, assembler, basic or anything else. But then it is translated to a hex file. And that can be programmed with your ISP programmer.

  38. Just that I have in mind. I must lean use atmel Studio 6 for code source code to Hex core. For after write it in attiny24 With avr programer. Well I have one more question... About leds . groups 8x2 connect in this Project + With. Every + Pins LEDs? And - send to system right?? TOM TNK U SO SO MUCH u are a big genious!!

    1. Manu, I would like to help, but I am afraid that I don't really understand what you are asking.

      I wonder, Manu, have you seen my other 4x4x4 cube, the "simple cube"? It is much easier to build and to understand. If you are struggling with the concept of charlieplexing, why not build the "simple cube" first?

      It uses a ATMega as controller, which gives you loads of outputs and which has much more internal flash memory for more pattern sequences.

      If you still want to build the charlieplexed version, there is an update post, showing a schematic.

  39. Tom I am trying to make a 3x3 led cube with RGB leds. How would I go about it? Make a 10x9 matrix and connect every three anodes together? My leds have common anodes.

    1. Alexander, I am sure there are projects on the web, which show you how this can be done.

      Anyway, don't use charlieplexing! This would make things really complicated.

      My advice would be to use conventional multiplexing with a 9x9 matrix. Your LEDs have common anodes, so organise your LEDs in such a way that the respective R/G/B cathodes for one colour of each level are connected. This gives you a total of 9 levels. The anodes of each column can also be connected. This results in 9 column anodes.

      All in all you would need 18 port pins, easily provided by an ATMega8 and the software could be very simple.

  40. Hi tom issit possible to use PIC 18f5420 for the programming.

    1. It might be possible, but you would have to rewrite the software from scratch.