Im new to electronics and have problems with calculating the resistors needed for driving an IR LED with an transistor.

My VDD is 3.3V, the LED needs 1.3V and I want to drive it close to 20mA, so I need a 100Ω resistor. But how can I calculate R2?


  • 1
    \$\begingroup\$ If you want to fully turn on the transistor you need to make sure that R2 is small enough. The only reason not to make it 0 is to limit the current that is going to control the switch. Find out the current gain (beta) of your transistor and follow from there... \$\endgroup\$
    – jpcgt
    Commented Jan 20, 2016 at 19:55
  • 2
    \$\begingroup\$ Since you just want to switch the NPN on/off the base resistor only needs to be there to limit the current to a safe value. Assuming your on/off voltage is also 3.3 V I would use a resistor between 3.3 kohms - 10 kohms. Actually you do not want to calculate from the transistor's beta as you want to drive the transistor in saturation and then beta becomes much lower (because of saturation). Just use 10 kohms I 100% guarantee that that will work just fine. \$\endgroup\$ Commented Jan 20, 2016 at 19:55
  • 1
    \$\begingroup\$ There's a great answer from Olin here, about simplifying your LED driving circuit: electronics.stackexchange.com/a/60868/91862 which tells you how to calculate the (only) resistance, with the benefit that any current needed to drive the transistor will also go through the LED, thus not wasting it. \$\endgroup\$
    – pipe
    Commented Jan 20, 2016 at 20:15
  • 1
    \$\begingroup\$ Neither will be stressful, but Olins suggestion will automatically draw the least amount of current from the microcontroller, without having to calculate any resistance that may or may not depend on the transistor. It's "auto-adjusting". \$\endgroup\$
    – pipe
    Commented Jan 20, 2016 at 21:15
  • 1
    \$\begingroup\$ @FakeMoustache 10k resistor would presume that beta in saturation is close to 60 (.0020/(3.3/10000)). Optimistic expectation, won't work for 2n5551 and the other medium power transistors. \$\endgroup\$
    – ilkhd
    Commented Jan 20, 2016 at 21:45

2 Answers 2


If you select R1 using ohm's law and get the correct voltage drop across the BJT (0.7+ volts, depending on transistor), then you will reach your current limit with a value of 0 for R2 long before the current gain matters. This is called using the BJT in 'saturation mode' and is most appropriate for applications where the BJT is a digital switch.


If you use a n-chan MOSFET instead, you don't have to worry about current gain.

Also, I would use a pull down resistor between the right side of R2 and ground so that the input is not floating when you want to disable it.

The major concern, with your current circuit, is selecting too small of R1, so that the circuit is dependent on the current gain (and a precise R2 value) which is known as 'forward-active mode', where your microcontroller needs to source excessive current and could be damaged.

Unless this is for a homework assignment and it's critical, I would use a MOSFET. If it's for homework, you'll probably need to use your textbook's method for providing calculations based on your teacher's expectations.


The BC547 has a current gain of 200 and an approximate Vce at saturation of 90~250mV at 10mA. So for 20mA you would have 180~500mV.

So your equation for Ic would be: 0 = 3.3V - 1.3V - Vce(sat) - Ic*R1 inputting best and worst case values for Vce you get... (2v - 0.18v)/(20mA) = R1(largest) = 91 (2v - 0.5v)/(20mA) = R1(smallest) = 75

For the gain (of 200) your equation for Ib would be: Ic = Ib*G Ib = 20mA/200

For the R2 value based on Vbe (PN junctions are 0.7v), you would have: V(input) - Ib*R2 - Vbe = 0 R2 = [V(input) - Vbe]/Ib inputting assumptions of 5v or 3.3v control input signals gives you... 5v – 0.7v = Ib * R2 => 43k 3.3v – 0.7v = Ib * R2 => 26k

All that said, if you pick a value of 100 for R1 and a 10k for R2, with a pulldown resistor of 100k you should be good to go. A large R1 makes R2 non-important and you want your pulldown large enough that it doesn't effect your Ib current (10x factor is safe).

  • \$\begingroup\$ Thanks for your reply. It's not for a homework, I want to control my TV using an ESP8266 ;) unfortunately I don't have mosfets here, so I need to order and wait :/ \$\endgroup\$
    – user97749
    Commented Jan 20, 2016 at 20:08
  • \$\begingroup\$ sure, lemme throw some calculations at you in another answer.. \$\endgroup\$ Commented Jan 20, 2016 at 20:11

You want to turn the transistor on in saturation, that means that you want to give it more base current that it need for the collector current. This will ensure that it has a low voltage drop across collector to emitter. When we have a volt of so across collector to emitter, the ratio of collector current to emitter current is given by the transistor's HFE. you transistor has a minimum HFE of 110. Let us use a ratio of one fifth that value 22. This will make sure that the transistor is fully on. One fifth of the collector current is 4mA. Let us assume you control this circuit with a 3.3V input. R2 will have a voltage drop of 3.3V - the base emitter voltage of the transistor. Assuming 0.7V for VBE, VR2 = 2.6V. R2 = 2.6 / 4mA = 650 ohms. Nearest E12 values are 680 or 560ohms. Either will do here.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.