My circuit works, but, I'm puzzled on something......

Thanks for reading. I made a simple led flash pattern on an Attiny85. I'm a novice at electronics so please forgive my ignorance.

The Attiny85 only offering 40mA per out. I wanted to use some bc337 on the outputs to allow more leds. The current set up uses two pins as outputs, with 4 leds on each output at 10mA a piece. Plenty bright for my application. But I wanted to double the lights from 4 to 8 on each output.

I have the transistor base connected to a 560 ohm resistor at the Attiny85 outs. The emitter is grounded, and, my leds are in groups of two, parallel, connected to +5V with corresponding resistors. The led cathodes are connected to the collector of the transistor.

Everything is working. But my question is this. For the life of me I cannot determine what "actual" resistor value I need at the base of the resistor. I just guessed with the 560 ohm one.

So two questions. How many mA of output does the bc337 offer? I'm still trying to familiarize myself with datasheets and am unsure.

Also, how can I determine the lowest possible resistor value for my transistor base in my circuit?

Thanks for your insight and patience. Much appreciated.

looks like the spec sheet shows 800mAdc as the max continuous-current rating for the BC337 spec sheet i found with a quick search.

You have a resistor in that circuit right? The BC337 will allow up to 800 millis but you typically want to make sure to put a resistor in line to make certain that you don't go over the rated current for the LED and cause failures.

The resistor on the base is pretty much just protection for the output of the pin on the Arduino. What you want there is a resistor to make sure that at full saturation on the transistor the Arduino output is not pulling too much current for that pin or for the cumulative current to not exceed the rated totals for the micro controller. In general, err to the high side. You, generally, don't want to go lower than needed on that.

A bipolar transistor is a current amplifier. The current going through the collector is a multiple of the current through the base. This parameter is called Beta and it's one of the important things to look for on a transistor's datasheet. The resistor sets the base current, which tells the transistor how much current it's allowed to pass.

Actually analyzing it and calculating the currents and voltages starts out simple but rapidly gets complex enough to require an electrical engineering degree. The easiest way is to put it on a breadboard and fiddle until it works.

It isn’t hard. If you can calculate a resistor for an LED, you can calculate the base resistor for the transistor driving it.

You do NOT use the beta. This is actually the linear, small signal beta. When a transistor is being used as a switch, it is being driven into saturation. The base current should be between 1/20 and 1/10 of the collector current.

So how much collector current? What is your total LED current on one transistor? It should be no more than 1/2 of the maximum rated collector current.

Let’s say 80mA through several series-parallel LEDs total. So you want about 4 to 8mA base current.

The transistor base-emitter voltage drop will be about 0.6V to 0.7V. In addition, the Arduino output drops a bit when it must drive an output. So we can just drop off 1V, and the remaining 4V will be dropped across the base resistor.

Simply apply Ohm’s Law: RB = 4V/8mA = 500 ohms, 4V/4mA = 1k. So anything between those values should be used for the base resistor. In fact, you’ll be perfectly fine with 470 ohms. Better to overdrive the transistor a little, really bad to underdrive the transistor.

When a bipolar transistor is saturated, the CE voltage can be very low, on the order of 0.1V to 0.25V, depending on the transistor. So you need to calculate the power drop. 80mA x 0.25V = 20mW. A TO-92 case can reasonably dissipate a couple hundred milliwatts without extra heatsinking, so it should be fine.

MorganS: A bipolar transistor is a current amplifier. The current going through the collector is a multiple of the current through the base. This parameter is called Beta and it's one of the important things to look for on a transistor's datasheet. The resistor sets the base current, which tells the transistor how much current it's allowed to pass.

Actually analyzing it and calculating the currents and voltages starts out simple but rapidly gets complex enough to require an electrical engineering degree. The easiest way is to put it on a breadboard and fiddle until it works.

:o it is probably the best way to get the magic smoke !! come on, the OP wants to use a transistor as a switch, no need of an engineering degree for that :grin: no need of Beta either, the datasheet gives the Ib value for an Ic value in a saturated state, you just have to use these values or, if too lazy to look at the datasheet, Polymorph's approximation should be used.

I fully support alnath and polymorph here... way to much angst has been generated about the criticality of the exact value of the base resistor when in reality it just needs to be a close enough value to make sure that the small signal transistor is "switched" on under the situation it finds itself in the TTL Logic 5Volt world. The BJT's are being used as switches in this application and not specifically as current amplifiers (though many love to argue this point). You can get reasonably reliable results with anything from the value you used (560 ohms) all the way up to about 4.7K ohms... this is why I stock a large number of 1K resistors as 1K ohms will give you a sweet spot value for most of the readily available small signal BJT's. EXamples: 2N3904, 2N2222A, 2N4400, and various BC5xx types.

Easy way - assume the Vbe of the transistor will be ~ 0.7V, one diode drop. Pump 20mA into it - not too hard on the arduino pin, usually enough to drive the transistor into saturation (full on), with whatever resistor is in series thus controlling the current flow.

(5V - 0.7V)/.02 = 215 ohm, so 220, 270 will work well.

If the Arduino output drops to 4.2V, then (4.2V - 0.7V)/220 ohm = 16mA, still enough to turn the transistor on hard.

bc337 datasheet shows Vbe-on of 1.2V as a MAX, sub that in an calculate R again. Figure 5 shows it will actually be lower http://www.onsemi.com/pub_link/Collateral/BC337-D.PDF

While I see where you are going crossroads, I actually consider 16 - 20mA into the base to be a wee bit of overkill. Very often, 5-10 mA is good enough to get the same results unless you have a really oddball small signal transistor.