# How to calculate Resistor needed in PNP Transistor Circuit

I am trying to calculate the resistor value I need to achieve 35mA in my circuit. Vcc is 5V. Can someone explain the values I need to find in the datasheet as well as formula to use to find the correct Resistor value? I would like to learn this for future projects using transistors.

Transistor used is S8550
UV LED used is here

simulate this circuit – Schematic created using CircuitLab

• What are the characteristics of your LED? Specifically, what is the voltage across the LED when it is passing a current of 35mA? How precisely do you want to control the current...is 35+/-5mA OK? Feb 8, 2020 at 1:27
• Ideally I would like to control it as close to 35mA as possible (LED is rated for 40mA max but I have settled on 35mA). I haven't been able to achieve 35mA in this circuit but currently have a 20 Ohm resistor for R2 and there is 3.8V across the LED but my current measured from LED (-) to Emitter is 13mA. I placed a 7 Ohm resistor for R2 hoping triple my current but now it only reads 19mA. Feb 8, 2020 at 1:32
• Are you sure, your GPIO can sink any current when logic high? Even if limited by gate resistor, LED and so, it might destroy your logic circuit if it isn't protected by TVS circuitry. Feb 13, 2020 at 9:33
• @Ariser I am using the Raspberry Pi 3B+ GPIO. How do I find out if it can sink a current? Feb 13, 2020 at 19:36
• Any reason you favour a BJT over a MOSFET? Feb 14, 2020 at 11:31

You should not use an emitter follower to drive that LED, the voltage drop is too high in relation to the supply voltage.

If your GPIO is 5V you can still use the PNP 8550 transistor as so:

simulate this circuit – Schematic created using CircuitLab

The value of R2 shown is probably a bit high, and depends on the LED Vf at 35mA.

Incidentally, your measured voltage seems a bit high to me, you may be putting too much current through the LED for continuous operation.

If your GPIO is 3.3V, you should use an NPN transistor such as a 8050 and flip everything around and reduce R1 to about 860 ohms.

Note that LOW = ON in the PNP schematic shown, with an NPN transistor HIGH = ON.

• my GPIO is 3.3V, even though the voltage drop is high is it possible to still achieve 35mA? Feb 8, 2020 at 1:48
• See my comments above. Suggest you use an NPN transistor (eg. S8050). You may be able to get 35mA with the emitter follower, but it won't be very stable. For example, as the LED and transistor heat it will draw more and more current and might fail. Feb 8, 2020 at 1:52
• It may draw a lot more than 35mA which could lead to early LED failure. Or you may get away with 0$\Omega$, hard to predict. Feb 8, 2020 at 1:56
• R2 = (5V - Vce(sat) - Vf) / 35mA. Vce(sat) is from the transistor datasheet. Vf is the voltage across the LED at 35mA (3.8V in your case). Vce(sat) might be something like 0.2V or 0.3V. So 27 Ohms or 30 Ohms might work. Feb 8, 2020 at 2:08
• OK, I have to correct myself. Looking at the datasheet for the 8050, Vce(sat) is probably much lower at Ic=35mA. Maybe only 30 or 40 mV. So you can almost ignore Vce(sat) in the calculation. So 30 or 33 Ohms might work well. Feb 8, 2020 at 2:13

I think you will need a higher voltage to supply the LED. Depending on the LED you are using, the forward voltage is between 4 to 6 volts at 20ma. This device has a much higher forward voltage drop than a standard LED. Look on the spec sheet for the Forward Voltage Vf for the exact LED you are using. Note on the second page that the Forward Voltage vs Forward Current varies greatly depending on the LED you are using. Also note that the maximum Forward Current is 40ma. Operating at 35ma is close to the maximum allowable. I agree with Roland that regulating the current would be better to protect the LED.

The function of R2 is to regulate the led current, which is very important. However, with 3.8V over the led and min.0.7 V over Q1 only leaves 0.5 V over R2. Not enough to really regulate the led current. When the led heats up, the led voltage will get a little lower, the voltage over R2 the same amount higher and the current quite a lot higher. Thermal runaway.

You need more than 5 V, or a current source with better feedback.

A fet instead of a normal transistor will give you 0.5V more voltage over R2, e.g. double voltage, and might also be cheaper.

Why not first forget about the transister (bipolar or fet) and just try to hook up the led with a resistor to 5 VDC and see if you can get a stable current? It may turn out that you will need a higher supply voltage, e.g. 7 or 10 volt. Fortunately, you can get very cheap dc/dc converters for voltages like 5 to 10 V, for under or around 10 buck (EUR/\$). With a higher voltage, you can work out more interesting schematics that actually regulate your current more easily.

• why is a fet better? there is less voltage drop? would the circuit be more like the left or right? Load to Vcc or Load to Gnd? Feb 14, 2020 at 0:03
• voltage drop of a fet can be very low, e.g. your 35 milliampere times 20 milliohm source-drain resistance. Also, a fet can be very cheap. Circuit is a different question, but not that difficult. Others already noted that your transistor diagram is not optimal. I just focus on R2. Feb 14, 2020 at 11:13