I am trying to create a 444 led cube with Arduino Mega. Each layer is going to have a common anode. And after stacking the layers all vertical leds share the anode.
Since Arduino Mega has enough pins. I am going to use 16 pins for anodes and 4 pins for cathodes (using npn transistors).
My question is what's the best way to power this cube? I can use 16 npn transistor for anodes also but I am sure there must be better ways to do.
Also if I use npn transistors or any other switching, will there be any delay in controlling the leds? Because I need to switch the leds fast to achieve the cube look.
Any help appreciated. Please note I am not an electronic expert but a software engineer
There are lots of different ways to "power" the LEDs. Using a driver like the ULN2803 (which is a package of darlington pairs) or a discrete transistors like you suggest, or a serial-driven driver chip like the TLC5940.
With that many LEDs you just need to make sure your I/O pins aren't sourcing/sinking more than 8 LEDs at any given time. (Technically 10 if they are drawing 200mA each, but it is good to have margin.)
You said "is there a delay in switching because it has to be fast." Fast is a relative thing. Eyes are really slow. Electronics are really fast. You'll be able to get plenty of "fast" effects using practically any method with the Arduino.
There are tons of resources on Arduino and the web on LED Cubes / Matrixes, look through the different techniques people have used.
When you say “sourcing/sinking more than 8 LEDs at any given time” do you mean LEDs directly connected to Arduino pins with resistors or even when using the transistors?
I was thinking if I use transistors and use the external power, I can use many pins at a time in my case maximum 16 pins. Please correct me if I am wrong.
I built a 5x5x5 led cube and I can highly recommend using a constant 16 bit current output shift register for your project. It really solves a lot of tasks such that no resistors are required, and only one transistor per cube level required.