Questions on General Use of Transistors

Hello! I have a few questions and probably some more that will string from others, but here's the first few.

In simple terms, is a transistor an electronic switch?

I also know that that they can change how current works, but I am not very certain I completely understand it. I have an abundance of these 2N3904 NPN General Propose Transistor

I saw an article online that says I should use this to evenly distribute current across multiple LEDs when wanting to turn on say 4 LEDs to one pin (not individual, when one is off, all are off, when one is on, all are on) on the Arduino. My question is, how can I determine what transistor I need for however many LEDs I will be wiring to one pin? Will the transistor above be adequate for 8 LEDs instead of 4? What if I wanted to wire 21 to one pin?

Thank you in advanced!

The transistor you link to handles 200ma... so if you had a string of leds 4 of them, that's 80ma within limits of 200ma so that's fine to use...

Transistors can be used as switches when saturated / fully switched on, they can have many other uses too!

How can you tell that it handles 200 ma? What is saturating it?

Check it out: 2N3904 Datasheet catalog

Saturating means turning on as hard as it can. That is getting the switch, the path between collector and emitter to be as conductive as possible.
It is the current sent into the base that is causing the saturation.

No one has answered the question about how to tell what kind of transistor to use in what situation. So, if I wanted to power 4 LEDs I use

If I wanted to power 21 LEDs then what what I use?

How do I know what kind of transistor works in a certain situation?

Then you need a transistor rated for a much larger current, with that many you may need to switch up to a power transistor or a mosfet...

Depending on the transistor, they can only handle so much current. The 2n3094 can't handle that much current, so I would advise you to go with a bigger power MOSFET. In my opinion, these are also easier to deal with, you just give the gate 5v and current goes through it. You can tell how much the transistor can handle by reading the schematic for the Ids max. The transistor I would advise you to use is something like this: IRF3710 MOSFET N-CHANNEL 57A 100V

I hope this helps

ok, first of all don't use pin 1... leave pin 0 and 1 alone.

secondly, the transistor you need is based on how much current your application requires, 1 20ma LED only needs 20ma of current, so a transistor rated 200ma will handle 20ma, a transistor rated for 5amps will handle a 20ma LED.

if you have 3amp LED, you can't use a 200ma rated transistor...

The one you decide has to fit the current requirements, if you had loads of money, sure go ahead you can spend $5 a transistor to drive just 1 LED, it's up to you to decide which transistor you need for the job.

It only becomes tricky when you start to get get into frequencies and capacitance, mainly for radio projects, but for every day use, pretty much any transistor npn or pnp will do the job for LED's.

MAXOFLIFE:
How do I know what kind of transistor works in a certain situation?

You look at the data sheet of the transistor and see if it matches what you want.
The major things are type ( PNP or NPN ) the maximum collector current, the power dissipation, the gain and the package type.

I know that is easier said than done and there are a lot of transistors out there. However there are selection boxes on the web sites of major distributors where you can tick the characteristics you want. For example on the Farnel site if you just put in transistor there are just over 27,000 types. So narrow it down to just junction transistors (bipolar) and there are a mere 3,500 or so. But you do get a filter so you can tick the characteristics you want. See this link:-

Note you can also arrange the results in price order.
In practice just stick to three of four transistors.

MAXOFLIFE:
How do I know what kind of transistor works in a certain situation?

Another part needed: A bit of math. Here are a couple of links to get you started (note, this is for bipolar transistors - mosfets are a whole 'nother game):

By no means is the above a complete set of equations, etc needed, but it is enough to get started with. When you move into larger power transistors (TO-220 and TO-3 case devices), you'll also need to get into power dissipation equations (and how to properly size a heat sink for proper current handling). The equations aren't very hard, but they do require a bit of thought and understanding about how things work and how the devices are constructed (to understand certain terms).

So then, if I had 42 LEDs and each one draws 20ma, then that that set of LEDs will draw 840ma or 0.84 amps in total. Then using the equation CollectorCurrent = BaseCurrent*CurrentGain

0.84 = 0.04*CurrentGain (Where the 0.04 come from the Arduino's output right? or is it 0.02 from the LED?)

CurrentGain = 21

Now, I might have done that completely wrong, but if I didn't, then do all I need to find is a transistor with a current gain of at least 0.84 amps with a current gain of at least 21 hfe?

do all I need to find is a transistor with a current gain of at least 0.84 amps with a current gain of at least 21 hfe?

Basically yes.

So then this would work?

No you need 0.84 Amps and this is rated at 0.8A. It is a bad idea to run a transistor at the rated current you normally run them at 80% of the maximum.
You then have to work out if the transistor can take the power dissipation, that is the saturation voltage times the current.

My data sheet for a 2N2222 is for a plastic case not a metal one, it has a collector maximum current rating of 600mA and a Vsat of 1.0V, so assuming that transistor has the same that gives a power dissipation of 0.84 watts. The data sheet for what you linked to has a maximum dissipation of 0.5 Watt.

So basically you need a more beefy transistor.

EDIT
The saturation voltage for that device is 2.0V at 500mA so you are dissipating 1.68 Watts

Keep in mind you want to have some form of margin, so that way you aren't drawing max power through the transistor and therefore heating it up dangerously. Usually the rule of thumb is at least 50% and often 100% for certain applications. So if you want a single transistor that will conduct 0.84A through a fairly stable load (Which LEDs are), you'll probably want one that will handle at least 1.26A. Additionally, you can put transistors in parallel and have them control/sink different groups of LEDs, and also distribute the power then. Then you can either connect them all to a pin (assuming you don't over-load the 20mA limit per pin), or you can connect them to different pins and therefore can control them separately.

Also, keep in mind that absolute max values are hard limits and exceeding them, even briefly, will most likely result in damage to your circuit.

Another IC to look at would be the ULN2003A, which is basically an array of transistors. Its simple to use and is great for sinking LEDs and other large current devices.

I guess the issue I'm having is understanding how everything calculates mathematically. Here's a Farnell search I made, are any of these transistors viable? If not, what did I input wrong?

You may want to take a basic look at how currents and voltages add up in series and parallel, and maybe read up on the basics of transistors. You can google them and there should be many university websites with lectures/notes. You'll probably understand better what you are doing. I'm not sure any of us want to type up a lecture on how basic electrical theory or transistors work.

In terms of specifics, I would select an appropriate range of Collector currents in your search and work from there. Your voltage limitations are unlikely