I just almost finished my circuit for controlling multiple LEDs. I have push buttons with LED rings, with preinstalled resistors in them. 5V common anode RGB LEDs and 9x 12V LEDs. I also have a display shield with a dedicated LED anode PIN on my Mega2560. I want to be able to dim all of those together with PWN from the NodeMCU.

I want to connect the 12V LEDs and the display backlight together to one pin of my NodeMCU. The LED backlight is rated as follows: 3.2 V, 4 LEDs in parallel, each rated for 20mA.

The problem is: The ground of the LED backlight is common with the whole display so I cannot use it separately. Thus, I cannot use a N channel MOSFET.

Looking at this video: https://www.youtube.com/watch?v=o4_NeqlJgOs I learned that it's not that easy to use a P channel MOSFET. I'm at the very beginnging of electronics and don't want to kill any part.

This is my circuit at the moment (still with the N channel MOSFET where the display stays on all the time because always connected to ground so it doesn't care about the MOSFET). Imagine the left bottom LED sits on the display directly on the Mega2560.

enter image description here

How can I use a P channel MOSFET?

Which gate resistor do I need to use with a P channel MOSFET?

Is the amount of needed gate resistor dependent on the amount of LEDs I want to drive? Or can I simply connect as many LEDs as I want to the drain (as long as the max current of the MOSFET is not reached)?

How big does the pullup resistor need to be? To how many volts do I need to connect the pullup?

Which parts might be damaged by the voltage spikes mentioned in the video and how to avoid this?

Will PWM still work correctly with a P channel MOSFET?

Can you suggest a suitable MOSFET model for this use case?

  • 2
    \$\begingroup\$ As an aside the search phrase "pmos high-side switch" should turn up lots of good answers \$\endgroup\$
    – sstobbe
    Dec 10, 2017 at 3:52
  • 2
    \$\begingroup\$ Also note that you have supplied a wiring diagram, not a circuit schematic. Your diagram gives no clue about what the circuit is supposed to do. We much prefer schematic diagrams with proper symbols for transistors, switches, LEDs, etc. There's a drawing tool built into the editor toolbar. \$\endgroup\$
    – Transistor
    Dec 10, 2017 at 8:35
  • \$\begingroup\$ There is a built in schematic editor here. Press edit, then on the schematic symbol. Draw your schematic. \$\endgroup\$
    – winny
    Dec 10, 2017 at 9:07

1 Answer 1


I found out myself :)

A PNP transistor after the MOSFET did the trick.

enter image description here

  • 3
    \$\begingroup\$ Thanks for getting back to us and if this is the correct answer you can accept it yourself. Note that your diagram still gives no clue what the problem was and how you fixed it without drawing out the schematic. \$\endgroup\$
    – Transistor
    Dec 11, 2017 at 21:36
  • \$\begingroup\$ But isn't it possible to derive the schematic from it? I guess an experienced person should be able to understand what was wrong. Or is it just easier with a schematic? \$\endgroup\$
    – dfsg76
    Dec 11, 2017 at 22:11
  • 5
    \$\begingroup\$ Yes it is possible to derive the schematic but that's your job, not your reader's. A schematic uses symbols that show the function of each pin on the device - gate, source, drain, cathode, anode, etc. The wiring diagram doesn't. They are often referred to in derogatory terms as "cartoons". (That's the downside of posting your question on an engineering site rather than a hobby site. A more professional approach is expected.) \$\endgroup\$
    – Transistor
    Dec 11, 2017 at 23:09
  • \$\begingroup\$ I hope to finish the schematic tomorrow \$\endgroup\$
    – dfsg76
    Dec 12, 2017 at 23:34

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.