# Basic help with calculating values for PN2222A LED circuit

I'm gonna be adding an IR LED to my Arduino Uno and I'm trying to wrap my head around the math used to figure out the exact resistor values needed to use a PN2222A transistor to drive the LED.

I know my LED has a voltage drop of 1.35V and I want to run it at 100mA and that I'll be supplying it with 5V from the Arduino. What I don't understand is the math for how to figure out the exact voltage drop of the transistor between the collector and emitter. And I'm also trying to figure out the math used to calculate the required milliamps that have to flow through the base of the transistor in order to fully turn it on (but not waste extra electricity).

I know that there is quite a lot of lee way in which resistors to use and the circuit will still work, but I'm hoping to figure out the math so that I can get as close as possible to using the exactly perfect resistor values.

## 3 Answers

What I don't understand is the math for how to figure out the exact voltage drop of the transistor between the collector and emitter.

You don't need an exact voltage. $0.2V$ is a reasonable estimate for most BJTs in saturation. The datasheet will give you more accurate values, under a range of operating conditions. $0.2V$ also isn't very significant to most circuits, so you can just ignore it. By ignoring it, you slightly reduce the current in the LED, which is erring on the side of caution, so isn't necessarily a bad thing.

And I'm also trying to figure out the math used to calculate the required milliamps that have to flow through the base of the transistor in order to fully turn it on (but not waste extra electricity).

There's a rule of thumb for a BJT used as a common-emitter switch, like this:

simulate this circuit – Schematic created using CircuitLab

when you want to drive the transistor into saturation (as you do here), make the base current 1/15th of the collector current. Again, the datasheet will give you more detail, but many of the parameters (like $\beta$ or $h_{fe}$) can vary over a wide range, as a function of temperature, operating current, and individual device manufacturing variation. The solution is to make sure you have plenty of base current so you are sure to saturate the transistor in all cases.

So:

$$I_b = \frac{I_c}{15} = \frac{100mA}{15} = 6.7mA$$

The base resistor will have the $5V$ from the Arduino across it, less the $0.65V$ drop of the base-emitter diode across it, and the current is then given by Ohm's law:

$$R_b = \frac{V_{R_b}}{I_b} = \frac{5V-0.65V}{6.7mA} = 652\Omega$$

Standard value of $680\Omega$ is close enough. The power in R1 is:

$$P_{R1} = \frac{V^2}{R} = \frac{(5V-0.65V)^2}{680\Omega} = 0.028W$$

...so even a 1/8W resistor is fine here.

You mention that you don't want to waste electricity. There's not exactly much being wasted here; probably the current limiting resistor in series with your LED is wasting more electrical energy than this transistor arrangement. But, there are a few ways around it. One is to use a MOSFET instead of a BJT, which has the advantage of nearly 0 gate (equivalent to the base) current. 2N7000 is common and cheap and would do nicely here.

Or, you can arrange the transistor as an emitter-follower, so the base current goes towards powering the LED, and is thus not "wasted":

simulate this circuit

For more detail, see Why would one drive LEDs with a common emitter?

The data sheet for the PN2222A gives a collector-to-emitter saturation voltage of 0.3V when the collector current is 150mA so I would be a bit conservative and assume the it is not less than 0.1V when Ic is 100mA. So with 1.35V across the LED you have (5.00 - 1.35 - 0.10) 3.55V across the series resistor. To get 100 mA through this resistor and the LED you need a value of 35.5 ohms, round up to the next standard value. The manufacturer also specified a base current of 15 mA for a collector current of 150 mA so you shouldn't need more than 10 mA base current. I'm not sure what your Arduino gives as an output voltage when supplying 10mA...let's say it's 4.0V. The maximum base-emitter voltage for Ic=150 mA is 1.2V so the difference is 2.8V and you need a 280 ohm resistor to get 10 mA. Now if the Arduino puts out a higher voltage, or Vbe is lower, then the base current will go up but this transistor can handle much larger base currents but you will be sure to get at least 10 mA.

I should mention that the choice of the resistor in series with the LED sets the LED current and I've designed for a maximum of 100 mA. If you need a tightly regulated current than you probably want to use a different circuit.

You need to "lose" or drop 3.65V in powering the LED from 5V. Some of it (maybe about 0.2V) is lost in the transistor being switched on leaving you about 3.45V to develop across a resistor in series with the LED. At 100mA into the LED (and thru the resistor) the resistor value is $R=\frac{V}{I}$ or $\frac{3.45}{0.1}$ = 34.5$\Omega$.

Choose standard values of resistance that add up 34.5$\Omega$ but observe that the power disippation will be $I^2R=0.1^2\times 34.5=0.345W$

Driving the base from the MCU is relatively straightforward - use a series resistor of about 220$\Omega$ - this will put about 20mA into the base and ensure the transistor is fairly well switched-on. I believe the Arduino can supply this current but check as I'm no expert on it.

However, I'd be tempted to use an N channel MOSFET and you can avoid the heavy current drive into the base. The FET, if you pick a decent one will also not drop any appreciable voltage when activated so the 200mV accounted for in the above equations should be ignored and a resistance of about 36.5$\Omega$ should be chosen.