# Calculate Base Resistor for LED Switch

simulate this circuit – Schematic created using CircuitLab

I have looked at several questions/answers regarding this topic on EE.SE and other forums I found with a search on google. I am only as familiar with using a transistor as to block current flow and to allow current flow, but never really had to worry about passing a specific current. After reading all of the questions I still can't seem to understand how to calculate the base resistor for a transistor to ensure it can switch enough current.

As an example, I will be using the following parts: WP130WDT/EGW LED, MMBT3904 NPN Transistor, and the 74HC595 Shift Register.

With the LED operating at 3.3v and 20mA I have calculated the base resistor with the following formula: Base Resistance = (Base Voltage - Vbe)/(Ic/Hfe) (3.3 - 0.65)/(.05/60) = 3180

Am I on the right track/using the correct values(I know the LED will only pull 20mA even though I calculated for 50mA Ic)?

My goal is to get ~equal brightness for all LEDS.

• noo schematic ? – Mitu Raj Dec 4 '17 at 17:18
• "With the LED operating at 3.3v", take a closer look at the $V_F$ in that datasheet, you will want to put another resistor in series with the LED. – Harry Svensson Dec 4 '17 at 17:18
• You should put the LEDs on the collector side of the transistor. With them on the emitter, the transistor will act as an emitter follower, so the voltage on the LED cannot be more than about 0.7 volts below the base drive voltage. – Peter Bennett Dec 4 '17 at 17:34
• @Peter Bennett with the LED being common-cathode can that be done? Is this a bad design/should I change something(without having to change the LEDs)? If need be, I have access to 5v as well. I could use that as the drive voltage. – SolveEtCoagula07 Dec 4 '17 at 18:06

Since you have a common-cathode LED, you'll want to drive it with PNP transistors in a high-side configuration.

simulate this circuit – Schematic created using CircuitLab

To calculate R1 and R2:

1. Average $V_F$ for the red and green sides, respectively, are 2.1V and 2.5V.
2. The MMBT3906 has a saturation voltage of ~0.4V at 10mA collector current.
3. Let's assume we want 10mA current through each LED $$R_1 = (3.3V - 2.1V - 0.4V)/10mA = 80\Omega$$ $$R_2 = (3.3V - 2.5V - 0.4V)/10mA = 40\Omega$$

To calculate R3 and R4:

1. $V_{EB}$ is assumed to be ~0.6V.
2. $h_{FE}$ is listed as 100 at 10mA collector current. $$R_3 <= (3.3V - 0.6V)/(10mA / 100) = 27k\Omega$$ (We'll use 10k since it's a common value and we want a good margin for error.)
• Just to make sure I understand how to do the second calculation, say I wanted Ic to be 30mA. To get the base resistor I would use: (3.3V - 0.6V)/(30mA/60) = 5,400 Ohms. Then I would simply calculate the current limiting resistor for the LED. So in this case, a 5Kohm resistor would be the best pick? – SolveEtCoagula07 Dec 4 '17 at 18:47
• Yep, that looks good! You could lower it even further if you'd like. Basically you want enough base current so that the switch is totally on, thereby minimizing the collector saturation voltage $V_{CE,sat}$. Of course there's nothing wrong with a little extra $V_{CE,sat}$ as long as the power dissipation in the transistor is within spec. – calcium3000 Dec 4 '17 at 18:51
• And just to make sure: the 74HC595 is powered by at least 3.3V, correct? – calcium3000 Dec 4 '17 at 18:52
• Yes, there will only be 5V (USB source) and 3.3V (LDO Regulator) available. – SolveEtCoagula07 Dec 4 '17 at 18:58