# Circuit to create X levels of brightness for a LED

If I'm here today, it's because I need some help for something that is, I think, easy for you. I am quite a newbie in EE but I am trying to improve myself :).

Here is the thing, I'll try to be as clear as possible with what I am dealing with. I am trying to figure out how I could create some level of brightness for some LEDs connected to an Arduino knowing that I can't use PWM.

Here is what I did since then :

I have three LEDs and I would like to have 3 levels of brightness for them. The LED I have are 3.02V / 15mA. So if I am not wrong, with a 3.3V power supply, I need a 20 Ohm resistor to bright one of them fully. With a MOSFET properly chosen, I will be able to drive it, am I right ? If so, with the above schematic, will I be able to have my 3 levels of brightness ? Since for each MOSFET, I have a different resistor value.

Are there others ways to achieve what I am trying to do without PWM ?

(sorry if my English is not perfect)

• This will, depending on your code, give you more than 3 levels of brightness. Consider what will happen if you turn on more than 1 pin. (Pin 1+2, 1+3, 2+3, 1+2+3) Commented Aug 30, 2016 at 9:47
• Actually I'll turn on only one PIN at a time. Commented Aug 30, 2016 at 9:54
• Just out of curiosity, why can't you PWM? Commented Aug 30, 2016 at 11:35
• Multiple additive currents are not all that useful with LEDs used for visual purposes because of the logarithmic human eye response. Commented Aug 30, 2016 at 12:00
• @ScottSeidman Actually because I am using an I2C I/O expander and there isn't PWM on it. Commented Aug 30, 2016 at 12:07

Source followers will not turn on completely so your circuit isn't great. If you want to ground the LEDs, you can use P-channel MOSFETs rated for 3V or lower drive, keeping in mind that the control signals will be inverted (low=on). Or you can connect the LEDs to +3.3 and use N-channel MOSFETs with the sources grounded.

Also, your paralleling of the LEDs is not the best. Assuming they are all very similar it can work okay, but it's better to give each LED its own ballast resistor otherwise slight differences in the forward voltages (they usually have a fairly wide range) will result in one LED hogging more current than its share.

The lowest value you have is 20 ohms so you could put ~60 ohms in series with each LED and then use 0 ohms/80 ohms/230 ohms for the other two resistors. For visual indicator or backlight LEDs the resistor values are not that critical and you can adjust them to convenient values by experimentation to get the visual effect you want, the key thing is that R1~R3 are equal, and they set the maximum brightness. The other two resistors add to R1||R2||R3, so you get the same effect as with 20R/100R/250R running the parallel set, or individual series resistors of 60/300/750 ohms on each LED.

simulate this circuit – Schematic created using CircuitLab

• You need 4 resistors less than what I was thinking of. +1 Commented Aug 30, 2016 at 9:48
• @Arsenal You can submit your answer as an alternative to get more even brightness, but watch out for sneak paths. You might need more transistors too. Commented Aug 30, 2016 at 9:51
• Wow thank you for your answer. That's an elegant way to achieve it ! But I am not sure to understand when you say "The other two resistors add to R1||R2||R3, so you get the same effect as with 20R/100R/250R running the parallel set, or individual series resistors of 60/600/750 ohms on each LED". Am I right If i say that when M3 is on, The resistor on each LED is 60+230 Ohm ? Commented Aug 30, 2016 at 11:11
• The effective total resistance is 20 ohms + 230 ohms = 250 ohms, for three, so the current through each is equivalent to 1/3 of that, or like each LED had an individual 750 ohm resistor in series. Commented Aug 30, 2016 at 11:47
• This answer provides the correct "ratios" of the resistors. However, the values are wrong because the 15 ma required, is for EACH diode. So, the total current required is 45ma. You will need about 75 ohms, NOT 20, to limit the current. Commented Sep 2, 2016 at 22:31

If you can increase the voltage of your power source you could use a circuit like

simulate this circuit – Schematic created using CircuitLab

As others have said, by turning on more than one mosfet you can have up to 5 levels of brightness (8 if you add a suitable resistor before $M_1$).

• No I can't increase it. At least not for now. Commented Aug 30, 2016 at 11:27
• Actually it would be something like 5 levels of brightness, due to M2 and M3 not making much of a difference when M1 is conducting, If R1 is placed in series with M1 then you will have 8 levels of brightness, but the value has to be adjusted so R1||R2||R3 = 10 ohms Commented Aug 30, 2016 at 13:25
• You're right, $M_1$ would have to have a resistor, too, to get the 8 levels of brightness. Thanks, I'll edit the post. Commented Aug 30, 2016 at 13:47

An "R–2R" ladder is a way to create a digital-to-analog converter (DAC). Connect an IO pin to each rung of the ladder and turn on different combinations of pins to produce different voltages.

EDIT: Had a play about in LTSpice just now (haven't got any microcontrollers on my bench at the moment so I've simulated the IO pins using pulse sources)...

With some tweaking I think these V & A steps can be massaged into the right ranges.

Using a LED so close to the input voltage is a bit of a bummer though, especially if PWM is not allowed.

The QTLP690C is the closest LED I can find in the default LTSpice library so the actual ones you are using might vary a bit.

A ladder probably isn't the best way I admit but the OP asked for alternatives to PWM.

• LEDs brightness is mostly current controlled, they have a relatively constant forward voltage drop. so IMHO varying the voltage is not quite what is needed, though it may be a means to current control. So, it might be helpful to create the whole circuit and see how the current varies. Commented Aug 30, 2016 at 14:47
• @gbulmer, has physics changed recently? :) j/k This does work if you choose sensible resistor values.
– user98663
Commented Aug 30, 2016 at 14:55
• "Has physics changed recently?" not in my world. The LED spec is "3.02V / 15mA", you only have 3.3V to play with, and human vision is logarithmic. So I would very much like to see how changing the voltage with an R-2R resistor ladder is going to work. So, by all means, define the circuit using R-2R resistors and I/O ports, stating your assumptions, and show me how you get 3, or more, distinct brightness levels on 3 LEDs. Commented Aug 30, 2016 at 15:07