# Picking transistor and base resistor to dim LED using PWM

I'm working on a project where I need to dim a 30 cm LED strip. I'm using a STM32 pin to drive the base of a NPN BJT-transistor. The pin is can source a maximum of 25mA. The LED strip consists of 12 parallel ordinary LEDs, each one in series with 1.4 kOhms resistance. The collector is connected to the LEDs, which in turn are connected to 8V Vcc. I have read that I should use a base resistor on the transistor, is it really necessary? And how do i proceed to select the right transistor?

• 5 or 3,3V? On stm. – Tony Stewart EE75 Mar 9 '20 at 16:20
• It's 3,3V output – ElecBaldwin Mar 10 '20 at 13:59

Yes, it is necessary to limit the base current for the transistor.

First, calculate the maximum collector current for the transistor. In your case, you need to know the maximum current that each LED will draw, which depends on the forward voltage of the LEDs (which you haven't told us). Make sure this is less than the specified maximum collector current for your transistor. If not, you need a different transistor.

Look in the datasheet for the specific NPN transistor (which you haven't told us) and find the minimum current gain ($$\h_{FE}\$$ or $$\\beta\$$) at a value of collector current equal to the collector current you need.

Divide the maximum collector current by the minimum current gain, and that tells you how much base current you need. Make sure this is less than the specified maximum base current for your transistor. If not, you need a different transistor.

Given the output voltage of your MCU and the $$\V_{BE}\$$ of the transistor calculate a resistor value that will result in the the desired base current. Select the nearest standard resistor value that is less than the calculated value.

• Thanks for the answer! I dont know the forward voltages of the LEDs or what NPN transistor i will use, that's why i didnt tell you :) – ElecBaldwin Mar 10 '20 at 14:02
• I'm glad I could help. The way things are supposed to work here is that you should "accept" the answer that helps you the most. If you want to wait a while and see if another answer comes in you can certainly do that. – Elliot Alderson Mar 10 '20 at 14:37
• Just one more question. Could you have a quick look at my calculations to see if they make sense? The LED and resistor pictured are the 12 parallel ones that i mentioned. I just measured Ic right now. The calculations: imgur.com/fY8NYUL – ElecBaldwin Mar 10 '20 at 16:54
• Looks reasonable to me. The assumption of 1V for $V_{BE}$ is somewhat high...we usually assume something like 0.7V. – Elliot Alderson Mar 11 '20 at 0:30
• Thank you for the help :) – ElecBaldwin Mar 11 '20 at 8:31