Electrical – Calculate Base Resistor for LED Switch

shift-registertransistors

schematic

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.

EDITED: added schematic.

Best Answer

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

schematic

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.)