I want to dim my ceiling LED light. I disassembled it, and it turns out that this is a led strip with many leds in serial. Its power supply is a 40V 450mA one, and I have built a circuit that could dim it with PWM from a microcontroller. Unfortunately a very slow flickering can be seen when I decrease the duty cycle under a threshold, and above this threshold it is just lighting with the same brightness.

For me it seems that the LED has a capacitor that stops the PWM from being effective if the duty cycle is high enough, and if it is lower, it starts to discharge, and when it discharges under the forward voltage of this LED strip, it slowly charges up again until the LEDs light up again.

The circuit I am driving the LED with is:

driver circuit

I have tried this with other lamps and it worked well.

I try to drive it with an ESP using the WLED firmware. It runs with an 1 kHz frequency in theory.

I probed the voltage between the source and the drain because I have the lamp built in the ceiling, and I have the negative side of the lamp and the negative side of the power supply wired down to my desk, but I think it shows the symptoms well, just when the drain-source voltage is low, the lamp will be high.

And also my scope is a cheapish USB one but the better ones are expensive for me and my use cases, sorry if the pictures are bad.

When duty cicle is high:


When it is off (It oscilates a bit because it picks up the mains voltage, but it is not that much):


And here is when the weird flickering happens:


My question is: I have 11 of this lamp, and I want to dim them individually. How could I dim these in a way so that the components would not cost too much?

I don't want to modify the lamps, as I rent this place and I don't own them.

Thank you very much.


The problem might be that my power supply is actually a current source. It is ambiguous for me if it is or not, but I uploaded it according to the comments.


  • \$\begingroup\$ Please provide a schematic of the circuit you are using, and any relevant code for the microcontroller. Also a scope waveform image, showing frequency and duty cycle. \$\endgroup\$
    – PStechPaul
    Commented Dec 16, 2022 at 19:28
  • \$\begingroup\$ @PStechPaul Thank you for your help. I added everything I could to the post. \$\endgroup\$
    – tvili999
    Commented Dec 16, 2022 at 19:57
  • \$\begingroup\$ Is the power supply constant voltage or constant current? \$\endgroup\$
    – bobflux
    Commented Dec 16, 2022 at 20:22
  • \$\begingroup\$ The 5v power supply and the 40 V are different, but their grounds are connected. The 3.3V rail is regulated from the 5v with a linear regulator. Both are voltage sources. \$\endgroup\$
    – tvili999
    Commented Dec 16, 2022 at 20:24
  • \$\begingroup\$ I have double checked and I think I am wrong, and I missed that my 40 V is actually a current source. I attached a photo of the power supply. Could you please give it a look? If this is a current source, please write an answer and I'll give you an upvote. \$\endgroup\$
    – tvili999
    Commented Dec 16, 2022 at 20:37

2 Answers 2


The driver looks like a 450mA current source with a 40V max output voltage. The label isn't clear, but normally voltage sources would be specified with "40V", here the extra "max" hints that it's a constant current driver.

That's not compatible with the PWM you're using: when the MOSFET runs at duty cycle lower than 100%, average current drawn by the LEDs will be lower. But the driver will try to enforce its constant current setting and increase output voltage to compensate, which increases current in the LEDs while the MOSFET is on: the LEDs will run at a lower duty cycle, but with larger peak current, and the average current will be the same.

So the driver will try to do the opposite of what your FET is doing, and it won't work.

Unfortunately a very slow flickering can be seen when I decrease the duty cycle under a threshold, and above this threshold it is just lighting with the same brightness.

This sounds like the driver believes the LEDs are disconnected when your duty cycle is low, so it just goes to sleep for a while, which will result in the kind of blinking you're seeing. When your duty cycle is high enough the driver will be able to regulate current in spite of the MOSFET so indeed you will get constant brightness.

In other words, this sort of PWM dimming works fine if the power supply is a voltage source, and the LEDs have some form of current control, for example resistors as in the usual LED strips. But it won't work with a constant current supply.

Since your LED strips consist of a series string of LEDs without resistors, the simplest solution would be to replace the drivers with dimmable constant current ones. These drivers can usually be controlled by 0-10V analog or PWM on a separate input, and they will adjust output current accordingly. But you'd have to buy one driver per light.

Another solution would be to use a constant voltage supply and add a resistor to set the LED current, then PWM with a MOSFET. This allows wiring many lights to the same supply. This would even work with constant current supplies that just clip to their maximum output voltage when the load is too low (they behave as current-limited voltage sources in this mode), but it looks like yours go to sleep instead, so it won't work.

None of these solutions seem compatible with a rental apartment though...

If you want to build interesting LED lights, I'd recommend getting some high quality high CRI LED strips, some aluminium profiles, a 24V constant voltage supply (for example Meanwell), this can be successfully controlled with an ESP32 without trouble.

  • \$\begingroup\$ Thank you very much, this was it. I tried just as a proof of concept to put my mosfet in parallel with the LED, and it did work, but the current regulating circuit in the power supply had a very visible and annoying ripple, and clearly the PSU is not designed for this. I will check the other options as well, I am very grateful. Thanks again. \$\endgroup\$
    – tvili999
    Commented Dec 16, 2022 at 21:59
  • \$\begingroup\$ You're welcome! These AC-DC supplies usually have a smoothing capacitor on the output so it's not recommended to short it with a FET because that will cause high current pulses when then FET shorts the charged cap... \$\endgroup\$
    – bobflux
    Commented Dec 16, 2022 at 22:16
  • \$\begingroup\$ I built a lights for my living room with 24V LED strips. Resistors on those strips do waste a bit of power, but with a constant voltage supply it is possible to have several PWM FETs, therefore several channels, which is really convenient for variable color temperature. \$\endgroup\$
    – bobflux
    Commented Dec 16, 2022 at 22:20
  • \$\begingroup\$ I have led strips and they are great, but they are only in one room, and I thought I could just make the ones I already have a bit smarter. And to be honest now I see a challenge in these lights. I might replace the power supply in the future and hope the owner doesn't read electronics questions. :D \$\endgroup\$
    – tvili999
    Commented Dec 16, 2022 at 22:51

I simulated your circuit using best guesses for unknown quantities. I was unable to reproduce the behavior, and here is the result at 20% duty cycle:

LED PWM with capacitor

Note the high capacitor charging current spikes. They are actually about 15A peak.

I also did a simulation with a 1A current source, limited to 68V with a zener. It takes a while to stabilize, but by 100 ms it looks like this:

LED PWM with capacitor, 1A current source

I tried to duplicate the waveform seen when flickering occurs, and I was able to get something similar by using a triangular wave at 100 Hz, simulating a poorly filtered rectified signal. Adding a capacitor across the power supply roughly duplicates the rising voltage during OFF times.

LED PWM 150 mA pulse current source

You can also see that the LED current varies widely. Adding a large capacitor across the LEDs just causes excess current to be drawn. But a large capacitor (1000 uF) across the power supply really seems to help, although it results in much higher current pulses when the MOSFET is ON. So varying PWM does not much affect brightness.

  • \$\begingroup\$ Thank you for your time and help. Now I think that @bobflux might asked the right question whether my psu is a current source, and it seems that really is. Thank you both for helping me. \$\endgroup\$
    – tvili999
    Commented Dec 16, 2022 at 20:44

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.