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.
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?