Building a MOSFET-Based PWM LED Dimmer

Thread Starter

cedricuk

Joined Sep 7, 2026
9
I’ve been looking into how a MOSFET can be used to control the brightness of an LED load with a PWM signal from a microcontroller.

One important consideration is choosing a suitable MOSFET based on its gate-drive voltage, current rating and on-resistance. Switching frequency also matters because it can affect switching losses, heat generation and potential electromagnetic interference.

For anyone who has built a similar circuit, how did you choose the MOSFET and PWM frequency? Did you encounter any issues with heating, flicker or electrical noise?

I’d be interested in hearing about different circuit designs and the trade-offs involved.
 

Reloadron

Joined Jan 15, 2015
7,954
When I was playing around with this my choice of MOSFET was always a logic level mosfet requiring a 5 volt gate, I used FQP30N06L MOSFETs. You get into a 3.3 volt uC I have used NPN transistors like a 2N2222 but your current is limited. PWM frequency is not much a concern. PWM is more about Pulse On verse Pulse Off time.

Normally I use an N channel MOSFET or NPN transistor for low side switching.

Ron
 
Last edited:

AnalogKid

Joined Aug 1, 2013
12,281
Many EMI rules do not apply below 10 kHz, so consider something like 1 kHz.

Unless you are driving a lot of power, magnetostriction won't be audible.

At this low frequency, switching losses will be a very small (trivial?) percentage in the overall circuit efficiency.

ak
 

MaxHeadRoom

Joined Jul 18, 2013
30,839
I made a Mosfet based circuit for a member here for controlling his LED lit Lava-Lamp. I used variable ratio PWM to slowlly ramp the brightness up and down over a 10sec period.
I would have to dig it out.
It used a 8pin micro to drive the Mosfet.
 

Thread Starter

cedricuk

Joined Sep 7, 2026
9
When I was playing around with this my choice of MOSFET was always a logic level mosfet requiring a 5 volt gate, I used FQP30N06L MOSFETs. You get into a 3.3 volt uC I have used NPN transistors like a 2N2222 but your current is limited. PWM frequency is not much a concern. PWM is more about Pulse On verse Pulse Off time.

Normally I use an N channel MOSFET or NPN transistor for low side switching.

Ron
Thanks, Ron. The FQP30N06L is a useful example of a logic-level MOSFET for low-side switching. With a 3.3 V microcontroller, I’d pay particular attention to the on-resistance specified at the actual gate voltage, rather than relying only on the threshold voltage.

I can see your point about PWM frequency too. The duty cycle controls the average power delivered to the LED, while the frequency can still matter for visible flicker, switching losses and noise depending on the load and circuit.
 

Thread Starter

cedricuk

Joined Sep 7, 2026
9
Many EMI rules do not apply below 10 kHz, so consider something like 1 kHz.

Unless you are driving a lot of power, magnetostriction won't be audible.

At this low frequency, switching losses will be a very small (trivial?) percentage in the overall circuit efficiency.

ak
That makes sense. Around 1 kHz seems like a reasonable starting point for a basic dimmer, especially if switching losses are a minor concern at that power level. I suppose the main thing is to check the actual LED load for visible flicker and any audible noise, rather than assuming one frequency will suit every setup. Higher frequencies may be useful where flicker needs to be reduced, but they also come with their own trade-offs.
 

Thread Starter

cedricuk

Joined Sep 7, 2026
9
I made a Mosfet based circuit for a member here for controlling his LED lit Lava-Lamp. I used variable ratio PWM to slowlly ramp the brightness up and down over a 10sec period.
I would have to dig it out.
It used a 8pin micro to drive the Mosfet.
That sounds like a neat application, especially the slow 10-second brightness ramp to create the lava-lamp effect. Using a small microcontroller for the PWM makes it possible to control the transition smoothly in software rather than relying on an analogue dimming circuit. I imagine getting the ramp timing and minimum brightness right would be important to keep the effect looking natural.
 
Top