I'm a new member in this forum, who has just received an Arduino Mega 2560 as a Christmas gift :) This means that I've never ever worked with Arduino before. but I have a big dream for about 2 years now, building an 8x8x8 LED cube and I'm going to try that as my first Arduino project. For this I need a little bit of help :) Please help me verify my theory about how I plan to construct it and give me useful advice if you can.
I'm an amateur when it comes to electronics. I've done some electronics projects in my life (like a binary LED clock controlled with a Raspberry Pi or a miniature locomotive driver which controls H0 locomotives with PWM signals), so know a few things, but there are quite many things out there that I don't know. In the last two years I have searched the Internet for how an 8x8x8 LED cube can be created. I've read many things, half of which I don't understand at all, so I'd like to create my cube in the simplest fashion possible, but not compromising the perfection of it. I hope to avoid using shift registers, latch circuits and other additional complications which I think will be possible, as it seems that I'm in a lucky situation because the Mega 2560 has a lot of I/O pins (54 digital pins + 16 analogue pins = 70 pins in total). That gives me enough pins to create the 8x8x8 cube with multiplexing.
Usually what people do is to connect the anodes of all the LEDs which are above each other, obtaining 64 columns and to connect the cathodes of all the LEDs which are in the same horizontal plane, obtaining 8 planes. This way you can light up the LEDs using multiplexing and you need 64+8 pins. But even the Arduino Mega 2560 does not have that many pins, so I had to find another way. And there is a pretty simple way to reduce the number of pins: divide each horizontal plane into two half planes. This way you will only need 64/2=32 pins to connect to the anodes and 8*2=16 pins to connect to the cathodes, a total of 32+16=48 pins! Well, the multiplexing software will have to handle the special kind of multiplexing which uses half planes, but that's OK (I've never written software for Arduino so far, but I'm confident that I can do it, I have more doubts about the hardware part :) ).
Based on the above approach, the LED cube can be made by dividing the cube into 16 zones (half planes). The anodes of the vertical LED columns are all connected together and the 32 resulting column groups are connected to a digital Arduino pin. The cathodes in each of the 16 half planes are also soldered together and each such group is connected to an Arduino digital pin. These 16 half plane groups are multiplexed from software, meaning that at any given time the current can only run through one half plane and the 16 half plane pins are switched very fast one after the other. Persistence of vision makes it possible for humans to see the cube as if all 16 half planes would be lit up at all times. This is the theory. To light up a given LED in the 8x8x8 matrix, we would have to pull the appropriate anode pin high and the appropriate cathode pin low, if I understood this correctly from other similar projects.
In theory it is that simple. In practice, however, it is far more complicated because of the Arduino's current limitations (global current limitation and per pin current limitation). I think the total current limitation of the 5V rail is 50 mA and in addition each pin has a maximum limitation of 40 mA. So it's clear that I'll need to power the LED cube from an external power source and that I'll need to add some transistors between the Arduino and the actual LEDs. I will use the signals coming from the Arduino pins to switch the transistor inputs and the transistor outputs will switch the actual, higher power LEDs. And this is the point where things start to become unclear to me. As we have established above, at any given point in time only one half plane should be lit up. that means that in the worst case 32 LEDs should be on at any given time. But as we all know, the multiplexing software can have bugs, which is likely to happen since it's my very first Arduino software. That means that we need to assume the worst: that it could happen that al 512 LEDs light up at the same time. That means quite an amount of current and we'll need some kind of hardware protection to limit the current and to protect the Arduino from such dangers.
But how much maximum current will be flowing exactly through the LED cube at a given time? To determine that, the fundamental question to be answered is: how much current is needed by a single LED? I'm planning to use standard superbright 5mm LEDs. Their datasheet states that they should be operated at 20 mA and people use this value most of the time. However, I have found that giving those LEDs 20 mA is a complete and utter waste of current. I've done some experiments and those LEDs are very bright even at 0.5-1 mA! Surprising, but true. SO I plan to limit the current through each LED with a resistor of appropriate value to 1 mA. I hope this can work with multiplexing (fast on/off switching of the LEDs), not just when the LEDs are continuously on. Please let me know what you think about this. If this can work, then at any given time no more than 32 mA should flow through the cube, or if the software has a bug and all LEDs light up, no more than 512 mA. Now this even questions the need to use transistors between the Arduino and the LEDs. The digital pins connected to the anodes would only be supplying 1 mA each and the digital pins connected to the cathodes would only be sinking 32 mA each. I'm thinking that I could add resistors to the anodes to limit the current to 1 mA and resistors to the cathodes to limit the current to 32 mA, for safety. Is this safe enough? Would this work? If the above suggestion is unsafe, I plan to use ULN2803 ICs for switching the LEDs based on the signal coming from the Arduino pins. If I do this, I don't know if I should add current limiting resistors between the Arduino pins and the ULN2803 input legs, or the ULN2803 chips already include some current limitation mechcanism which will make sure that the current flowing through each of the Arduino pins and the total current flowing through all the Arduino pins is small enough. Between the ULN2803 output legs and the LEDs I plan to add current limiting resistors which would limit the current through each LED to 1 mA. Also, if I'm going for the ULN2803 based approach, I'm still thinking of avoiding an external power supply and taking the current from the Arduino's 5V rail. I'll still need to add a resistor to limit the total current taken from the 5V rail to a toal of 32 mA, in case the software goes nuts and turns on all the LEDs.
What do you think of my approach. Is this achievable at all? is it oversimplified? As I said in the beginning, I want to keep it as simple as possible, but I do not want to endanger my Arduino board in any way, so hardware protection against too big currents is a must have in all possible ways.
Thanks in advance for any good advice you might be able to give me! Andras