I was wondering one thing: There are many people out there who has built an LED cube with the help of NPN transistors in order to control each layer. Why do people use NPN transistors in order to control each layer? Isn't it possible to just use a cable to directly connect it to one of the outputs of the Arduino?

Cannot seem to find an answer on the internet, so I am trying to post my question here.

I've never built one, but I'm gonna go ahead and say that they use an NPN transistor to enable the use of an external power supply to power the LED cube, as to not draw too much current from the arduino and burn it up. That way, the arduino just sends the high/low signal, and doesn't have to try and supply the power.

"Beer is proof that god loves us and wants us happy" - a popular misquote of Benjamin Franklin, but true nonetheless.

I was wondering one thing: There are many people out there who has built an LED cube with the help of NPN transistors in order to control each layer. Why do people use NPN transistors in order to control each layer? Isn't it possible to just use a cable to directly connect it to one of the outputs of the Arduino?

Cannot seem to find an answer on the internet, so I am trying to post my question here.

Arduino pins can only handle a maximum of 40 milliamps.

(and even 40 milliamps isn't recommended for constant use).

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

I was wondering one thing: There are many people out there who has built an LED cube with the help of NPN transistors in order to control each layer. Why do people use NPN transistors in order to control each layer? Isn't it possible to just use a cable to directly connect it to one of the outputs of the Arduino?

Cannot seem to find an answer on the internet, so I am trying to post my question here.

The answer is in how a cube is wired to operate. There are usually individual drivers (either direct avr output pins or shift registers output pins) driving the vertical columns of a cube. And as such depending on how many leds the given pattern wants to turn on for a given cube 'level' (or "layer" if you please) the total amount of current demand for that level can vary from 0 ma to 20ma X the number of leds for that level, so for a 5x5x5 cube there can be as many as 25 leds that must be powered, or 500ma, so the 'level driver' current requirement is way too much for directly connecting to a digital avr output pin, therefore a switching transistor rated for well above the worst case "level" current requirement is needed.

Thanks for all the answers, yes Lefty it makes very sense. But if I do not want to turn on all the leds at the same time and use multiplexing on the programming, is it possible to skip the transistors for a 5x5x5 cube? BecaUse it seems like the leds are very dim when we have our own LED cube 5x5x5 on, especially when we use multiplexing and we do use transistors

Thanks for all the answers, yes Lefty it makes very sense. But if I do not want to turn on all the leds at the same time and use multiplexing on the programming, is it possible to skip the transistors for a 5x5x5 cube?

Well you can power a 5x5x5 LED cube from the arduino itself by using shift registers and 5 npn transistors for switching to gnd. I run my cube @ ~13mA per led. So if I light up 1 layer it only draw 325mA + some current for the chips/uno itself of the 450mA(or 500mA, however I'm not sure) available. Though its working you can't light up more than 1 layer at the time, because of this you have to multiplex the cube... In my thread there are some pics of my cube as you can see I only use 5 npn transistors:http://arduino.cc/forum/index.php/topic,144057.0.html. You have to use those transistors because the arduino can only sink up to 40mA per pin, with 5 transistors you only need a limited amount of current from the arduino pins to the base of the transistor to switch it to gnd.

I have a question regarding LED driving, every time I think I understand things I realise I don't. I know this is getting a bit OT, please forgive that but there seesm to be some knowledgable people here, and this does seem to be very close to topic,switching LEDs with NPN transistors.

Basic task : I want to drive some common cathode RGB LEDs with an Arduino. I've got a bunch of IRF520s on hand, also small transistors like 2N2222, BC557.

Does this circuit even make sense? Is it the best way to do what I want to do? (I'll settle for 'works' as a definition of 'best')

Can't inline images ?

I was planning on running the LEDs in 'parallel' ie connecting all their red pins together and so on, then using one FET for each colour channel. I've tried that woth the 220ohm resistors and the current flow is OK, a bit low but the LEDs are bright enough. I know I dont need the FETs, they're 10A units and some little transistors would do fine. Also, PNP transistors would be fine, I just happen to have the IRF530s.

Yep. I put the second LED in there to indicate "more LEDs go here...", that is, the same colours all tied together. Probably wasn't that clear of me in the diagram. If the circuit's OK apart from that I'm happy.

What is the complete IRF520 or IRF530 part number being used?http://www.digikey.com/scripts/dksearch/dksus.dll?vendor=0&keywords=IRF520http://www.digikey.com/product-search/en?lang=en&site=us&KeyWords=IRF530

Some are Logic Level, and will switch from 0-5V just fine.Some are Standard Level, and will not switch full on unless 10V or more is available.Some are N-channel and are really intended as current sinks (use between cathode and Gnd)Some are P-channel and are really intended as current sources (use between 5 or 12V and anodes)

? is a marking I can't decipher, looks a bit like a triangle. They're in a TO220 package.

From the IRF530 datasheet, almost all are logic level gated, so they'll switch properly with the Arduinos 5V? That'd be good news.

I'd read that FETs are better chosen to suit the load given them - not the few hundred milliamps this will use where, but also the FETs have a much lower on resistance, so surely I'm better off doing things the way I'm doing them?

Also, I left a wire out of that diagram, I was just going to connect all the anodes for a particular colour together, then to the resistor and FET, is that OK? At this stage there's only 4 LEDs ie 4 LEDs on each of the RGB channels.

Okay, that's an N-channel MOSFET.Better suited as a switch between cathode & Gnd, but if you have common cathode RGBs and its a 5V only system then using between 5V and a resistor to each anode might be okay.If you use 1 resistor and parallel up the Anodes you may get uneven brightnesses, or burn them out if the LEDs have different current flows between them.