20 October 2012

The Charlie Cube Mark II: 4x4x4 - Update

Build this simpler version instead!

When I wrote my post on my charlieplexed LED cube, I never meant to publish build instructions. There are plenty of instructions around and a regular LED cube is much easier to make.

Instead, I wanted to show that it is possible to use charlieplexing for such a cube. And I wanted to share my thoughts on how I got there. So I never published schematics for the cube. Also, it is relatively difficult to draw a 3D electronic structure on a 2D schematic.

But quite a lot of people asked for a schematic. So in the end I just tried my best to draw it in an understandable way. I still think that for someone with some basic knowledge of electronics it is better to try to follow my explanations in the original post. But anyway, here it is.

But let us start with the components first. Here is a list. 
  • 64x LED, blue, ultrabright, wide angle
  • 8x 1k ohms
  • 8x BC337-40
  • 1x Atmel microcontroller ATtiny24 (or better ATtiny84 with more memory)
  • 1x perf board
The list is very short, perhaps that is why there is so much interest?

The Groups
 In order to avoid overloading the schematic I am using a sub-circuit, which I call a group. This is just a set of 8 LEDs. All anodes of those LEDs are connected and the LEDs form a structure of 2x4 LEDs. See the original post for an image. I used those groups as my basic building stones for the cube.

And here is the (trivial) schematic of a group:
It has 9 connections: 8 LED cathodes and 1 common anode. 4 of these groups are stacked on top of each other to form half a cube.

The Cube
And here comes the rest. In the upper half of the schematic I tried to show the 8 groups in a 2.5D fashion. And at the bottom there is the controller and the driving transistors - one for each group. The image is rather large. It is best to click on it to get the larger version. But it seems that even then, the blog reduces the image in size. So I will put it on my download page.

So there it is. The full schematics of my cube. I hope it helps at least a few people. But I am not so sure...

What's next?
My feeling is that the low part count of my cube is what gets people interested. But the fact that I am using charlieplexing means that it is really quite difficult to understand, especially for people with only a basic knowledge of electronics.

So I decided to build a really simple LED cube. It will have a very simple 4x4x4 LED structure and use only 2 cheap active components (apart from the LEDs of course). And I will write a post with detailed building instructions. LED cubes for the masses! :-)

Stay tuned!


  1. Hi Tom, I am very impressed with your design of the the charlieplexing 4x4x4 led cube,and have decided to follow your instructions to build one myself. I have used your 2.5D schema (plus other info)and have built/wired up everything. Once I plug in my power source, the cube just lite up and no action. If I removed power to half of the cube, then I will get some action, but nothing close to what I have seen in your demo vid. I am wondering if you would offer your thoughts what went wrong with my build. I wired all the common anode to create a 2x4 and cathode as column. I am using ATtiny44A. I have rewired many, many times to ensure I followed what you have set in your 2.5D schema. I am not good with reading the programing language,but I am trying. I just thought to ask you to see if you could spot something before I could figured out the program assignment. Thank you very much for your time Tom. Best regards. p/s: Let me know if you need more info. from me.

  2. Hi again, I think I found my problem (I hope. Ordering the right part this time). I am using BC328 (PNP) instead of BC337/338 (NPN). Will see once the right transistors arrived. Thanks

  3. Hi Anonymous,
    let me say first that I think it is great that you are trying the build.

    It seems that you found the problem. I'd say with PNP transistors you would get the effect that you described.

    As a general advice: You could try to feed the cube directly (one common anode, one cathode) with power (use a resistor and a low voltage suitable for your LEDs!). You should be able to activate every single LED by cycling through all possible combinations.

    And please let me know how it goes!

  4. Hey Tom,
    I'm so happy to tell that I followed your advice (one common anode, one cathode) with power (resistor and low voltage) voila, magical led showtime!!! It took me a while to figure out what you are telling me(lack of electrical components understanding on my part)and finally got it right. Thank you very much for your help. I truly learn a lot following your build, include loading c onto ic etc. Thanks again and hope to see more interesting build from you in the future. Best regards...K

  5. Hi K,
    this is excellent news. Sorry if I kept my advice too brief. It is always difficult for me to find the right level of abstraction, because I don't know your level of knowledge of the black art of the electrons. :-)

    And thank you very much for the positive feedback. I do the whole blog for fun - for mine as well as for the reader's. So feedback like this will encourage me to keep it going.

  6. Hi Tom,

    Yeah, My level of knowledge on electrons is absolutely beginner (btw,your instructions were perfect). That's what makes it more challenge and fun to work on a project like yours. Since I am using Attiny44 for this project (more memory room), I am trying to understand your code so that I can add more action to the cube. What I want to add is all 16 LEDs moving from top to bottom (level to level) and side to side etc. Any hint on how to understand your code would be greatly appreciated. Have a great weekend Tom!!!

  7. Hi K,
    you certainly haven't chosen a project for beginners there. So I am impressed that you got it working.

    My code is probably not easy to understand. You are absolutely right to use a tiny44. The tiny24 has very little memory. So you can't just store sequences of LED patterns.

    Instead, I implemented my patterns by synthesizing them. I started out with simple routines to do this, like "set LED no. X". On top, I wrote routines that use those to set columns, planes or other patterns.

    And of course there is the weird set_pattern routine which does all you could think of. I found that many elements in a cube are just regular sequences if you line the LEDs up in a long row.

    There is even a routine to rotate the cube contents in 90° steps in every direction. But it took too much space, so I had to take it out. The idea was to implement a sequence once and play it back in several directions.

    Enjoy your cube!

    1. Thank you very much for your reply Tom!!! Yes, I do enjoy my cube, every minute of it ;-) Thanks again for your time spending on answering my questions. Take care....K

  8. hey I wanted to build this cube following your steps but I had a few questions. first off I just wanted to let you know that I am very impressed by the way you designed the cube. My questions are as follows, first, How to you put the C code on to the micro chip? also in your schematic diagram you put for example "PR4", "TR0" and "PA0" I wanted to know if the number in each of these correlates to the number of one of the pins on the chip. If that is so then if the number is 0 then do I not connect that section of the cube or is there a pin named '0'? for example if the chip were to have 5 connections. would they be numbered "0,1,2,3,4"? or "1,2,3,4,5"? As you can tell I am fairly new to micro chips lol. I have been messing around with electronics for a few years now but I never dabbled in to the world of micro chips. however I know how basically all electrical components work including Transistors and resistors. its really just the chip and adding the code that confuses me. I hope you can shed some light on my confusion thank you for your time and good job on your cube!

    1. Hey, there. OK, lets start with your first question: how to get the C code on the chip. There are a lot of tutorials on the net. So it wouldn't make sense for me to write yet another one.

      But basically there are two steps. First you have to translate the C source code to something that the controller can understand. This is called 'machine code'. I use the Atmel Studio Version 4 to do this. It is free and can be downloaded directly from http://www.atmel.com/Images/AvrStudio4Setup.exe . There are other possibilities, like the gnu tool chain.

      You end up with a xyz.hex file.

      If you are impatient, I can send you that hex file. Most people prefer the source code, because it is readable.

      Now you need a programmer to transfer the data onto the chip. Again, there are lots of possibilities. More recently, I have been using a cheap Chinese USBasp clone (about 3€). Check out my post on this issue (April 2012). Great value for money!

      Some of the controller pins double as a serial port with data lines (MISO/MOSI), a clock (SCK) and RESET to shift data in via a serial format. You just connect those pins (plus GND) to the programmer via a pin header.

      PA0 and PB0 refers to the port pins of the controller. Perhaps you overlooked the lower part of the schematic? The labels with the same name are connected. You might want to go to the download section, get the schematic and print it. PA0 e.g. is pin 13 on the chip.

      With microcontrollers basically everything starts with 0. So the 8 bits of a port are PA0 ... PA7. You will get used to this after a while.

      Keep at it. If you have a good knowledge of transistors and other components, you can do it. And over time you find how simple projects can be, when you have a microcontroller at your disposal.

      Any more questions, just ask.

    2. Oh and one more thing. This cube isn't really practical. It uses a minimum number of controller pins ("because I can"). But this is not easy to understand or build.

      But I almost finished the next one, which will be much simpler. Just give me a few days...

  9. Okay great thank you so much and I cant wait to see what you build next! I appreciate all of your help.

  10. hey I have built the 8 sets of 2x4 LED's and now I wanted to know what I need to do because I am a little confused as to why you have to "bent wires hanging down from each columns? what are they connected to? are these bent wires simply just to connected all of the columns together e.g all of the cathodes together?

  11. Most, but not all of those cathodes are connected to the cathodes of the LEDs in the next lower group. But this has to be done as shown in the schematic.

    It is pretty simple for the inner "slices" of the two half-cubes. Because as can be seen in the schematic, you just connect the cathodes in columns. But it is more difficult with the outer slices. Follow the schematic carefully.

    In the schematic, the cathodes and anodes end at labels. These labels can then be found again at the pins of the controller and transistors.

    This is just a way of avoiding loads of wires all over the schematic.

    1. Okay so basically if I understand correctly, the end result will be all of the anodes being positively charged and the chip controls each LED by sending a negative charge through the NPN transistor straight to whichever column (or cathode) it wants to light up. Also for this project I have 8, 2N3904 NPN transistors. Can I use these transistors with the 1k ohm resistors? or does it need more protection? E.g 220 ohm resistors?

  12. The microcontroller sets _one_ port "high". This means that the connected transistor switches on and drives current into the common anode of one specific LED group. Then every port that is set to low will make one specific LED light up.

    I think you understand the principle, you just have got it the wrong way round.

    Forgive my asking, but are you sure this project is within your abilities? I have a feeling that you are a bit too ambitious.

    Also, are you aware that the controller needs to be programmed and are you able to do this?

    1. Oops, forgot: The 2N3904 will be fine. The 1k Ohm resistor is OK. Actually, 1k stands for 1000, so that resistor is bigger. meaning it lets less current through (compared to the 220 Ohms).

  13. Sir i have some trouble with a C Source Code Can you help me ?? I just want only a Source Code in HEX file and please send that one to 26589t@gmail.com .if my invitation is disturb your precious time please dismiss this comment.Thank you for your kind :D

    1. Just a little bit sir. Can i give your contact e-mail for asking a way to slove some problem in the future . Because im very bad in microcontroller section . Thanks :-)

    2. Hi Ton,

      I sent an email to you with the hex file and some comments. Did you get that? It contains my email address. Feel free to contact me.

      Alternatively, click on my name above of this comment. This takes you to my profile page and there is a link to send me emails (on the left border).

      I don't want to publish my email address here, because I fear that could lead to spam emails.

  14. Hi Tom,
    Can i use the same code to upload onto an atmega8l instead of using attiny24 with the same schematics? If so, which 9 ports can I use on the atmega8?

    Thanx in advance.