# Calculating Values for PN2222A LED Circuit

• Yoyo G
In summary, the OP is trying to figure out how to use a PN2222 transistor with an Arduino Uno to drive an LED, but is having difficulty understanding the math involved. They have determined that they will be using a 1/2W resistor and that the transistor will need to be driven at saturation in order to function properly.

#### Yoyo G

I'm going to 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.

You don't need to calculate it exactly. Since the transistor is being used as a switch you can start by assuming that it's all the way on (or off). We call this saturation.

The collector to emitter voltage will be about 0.4V (VCE(sat)) on the data sheet. This plus the 1.35V across the LED will leave 3.25V across the resistor in series with the LED. For 0.1A flowing through the LED that means you'll use a 33Ω, 1/2W resistor.

The base current must be more than enough to support the 0.1A collector current. So we need to guess at the minimum current gain in this configuration this is called β or hFE. For this transistor we can assume β>50 (from the data sheet), which means you need at least 2mA of base current. The base emitter voltage (VBE) will be about 0.7V. So if you are driving the base from 5V when on, you'll have 4.3V across the base resistor. So 4.3V/2mA = 2.15KΩ, but I would round that off to 2KΩ.

This is a better datasheet: https://www.mouser.com/datasheet/2/302/nxp_pn2222a-1189038.pdf

Use common emitter connected to ground.
Saturation voltage Vce(sat) of 2N2222 will be about 100 mV. Check that on datasheet.
LED requires 1.35 V at 100 mA. (That makes it an IR LED).
5 V supply.
5V - 1.35V - 0.1V = 3.55 volts across resistor.
3.55 V / 100 mA = 35.5 ohms which is the limit resistor. Use 33R.
W = 3.55V * 0.1A = 0.355 watt; so use 0.5 watt.
If 2N2222 current gain, beta = 100. Check the minimum beta.
Then base current must be 100 mA / 100 = 1 mA.
If logic high from port is 4.75 V and Vbe = 0.65 V; Check that on datasheet.
Then resistor drop is 4.75 - 0.65 = 4.1 volt at 1 mA..
Base resistor must be 4.1 / 1 mA = 4k1 so use 3k9 or 3k3.

@DaveE we are in the same ballpark.
@Yoyo G
This is a situation where you could halve the power consumption by placing two LEDs in series and allowing them 50 mA. Total light output is then the same, but less heat comes from the LED current limit resistor. The design process is the same but two series LEDs total voltage is 2.7 V.

• DaveE
Baluncore said:
@DaveE we are in the same ballpark.
@Yoyo G
This is a situation where you could halve the power consumption by placing two LEDs in series and allowing them 50 mA. Total light output is then the same, but less heat comes from the LED current limit resistor. The design process is the same but two series LEDs total voltage is 2.7 V.
Yes. This can be a pretty sloppy design and still work well. For example, my datasheet says β(sat)>50, but in the real world of one-off hobby designs, it probably is 100. I suppose it's really a question of how far into saturation you drive it. VCE(sat) = 0.4V and β(sat)>50 aren't that realistic in combination. If it comes out of saturation β will rise. I always tend toward the more conservative just because of the companies/markets I worked for.

It's the 1/2W resistor that people will screw up, IMO.

• Baluncore
Yoyo G said:
I'm going to 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.
This OP has a history of only posting one post per thread and not answering follow-up questions asked of them, but I'll try anyway.

@Yoyo G -- What speed / frequency are you going to be turning this IR LED on and off? If it's only a few kHz, then the PN2222 should work with the previous circuit advice. If it's 1MHz or above, you will need a different circuit to drive it.