# Control LEDS with PWM and transistors

I have three transistors that are each connected to 5 LEDs like so.

I am attempting to increase and decrease the current through the LED's in a linear fashion by increasing the current in the base of the transistor. So if I decrease the 3mA to 1.5mA, I want the LED current to go from 16.25mA to 8.125mA. However, currently this setup does not do this. The current in the LEDs does not significantly decrease until the current source is a small percentage of its current value.

The 3mA sources in my diagram are modeling the pwm outputs of a microcontroller. (Their max current.) I need to control the brightness of the LEDs by changing the duty cycle of each PWM.

I'd rather not have to use a LED driver. I'm also aware of the use of lookup tables to correct the exponential factor. Is that my only option?

• What is the $h_{fe}$ of the transistors? – Ignacio Vazquez-Abrams Apr 24 '15 at 21:52
• It's the 2N2222 so I believe its about 50. But I could be wrong. – codedude Apr 24 '15 at 21:57
• You're going to want to switch to something with better power handling; the transistors are going to start to burn as you pull them out of saturation. – Ignacio Vazquez-Abrams Apr 24 '15 at 22:02
• Any recomendations? – codedude Apr 24 '15 at 22:05
• A bit of searching finds the PHE13005, but the voltage handling is a little overkill. – Ignacio Vazquez-Abrams Apr 24 '15 at 22:20