I am working on a LED board for a flashlight powered by a 3.7 V battery. The flashlight has a dual light feature: both white and UV light are available.

Four signals are sent to this board by the motherboard: the VCC (3.7 V), GND, an "LED selection" signal (to switch between the UV LED and the white LED), and the PWM signal to control the brightness.

The control signals are provided by a PIC16F887, which is also powered by 3.7 V from the battery.

Here is the desired operation:

  1. When the LED-selection signal is 0, the white LED is lit; when it is 1, the UV LED is lit.
  2. The PWM signal is common for both LEDs, so that when the current operating LED is switched, the duty cycle is applied to the other one without having to set it again.
  3. Finally, the current is taken from the VCC, so the PWM is applied to a MOSFET that will allow the current to flow through the currently active LED at the desired frequency and with the desired duty cycle.

I also want to use as few components as possible to make the board compact (it must be fitted in a limited mechanical package: 39 mm x 23.5 mm)

Here is a picture of my actual circuit. I use three MOSFETs because the current drawn will be greater than 200 mA (at least for the white LED).

enter image description here

My questions are:

  1. Is the actual circuit correct in its structure? I tried to simulate it in Tina and it seems like it is working as I want (I replaced the "LED selection" with an On/Off switch and the PWM by a clock).
  2. I am not sure of the wiring of the PWM MOSFET (Q1). Normally, the source should be wired to GND as the transistor is N-channel. I don't really know if a P-channel MOSFET would be better for this application. However, I've read that P-channel MOSFETs are used if the signal voltage is of the same range as the power supply voltage (which is the case here) and to connect the source to the positive side of the load so I am considering replacing Q1 with a P-channel MOSFET. However, again, the simulation shows no problem with the operation of this circuit (which I doubt is accurate).
  3. Should this board have its own power supply rectifiers so that the LEDs are fluently supplied? The wires between the motherboard and this one will not be longer than 5 cm so I suppose that it should not cause problems.

As requested, I am giving more details on the simulation:

Because my CAD software (Kicad) is not very permisive with simulations, I recreated the schematic on Tina. The LEDs are inactive when filled in Grey, and active when blank.

Edit: I replaced the PWM N-Channel MOSFET (Q1) by a P-Channel MOSFET with the G pin linked to VCC instead of ground

It solved the PWM switching issues, now, the LED are properly switched On and Off depending on the PWM frequency and duty cycle. enter image description here

New results are as shown (from simulation):

With the "LED selection" switch open (LED 2 powered), I get the following results:

enter image description here

And with the switch closed (LED 1 powered), I get the following:

enter image description here

Since the LED I want to use have a typical forward voltage of 3.1V at the desired current, it should work with this circuit, but the margins will be low so I have to be sure that my supply voltage is not lower than 3.7V.

In the case where LED1 is powered, no voltage is passing through the second LED and the voltage is not high enough (2.3V in the simulation) to compensate for the forward voltage, so it will definitely not be lit when it should not be.

Note: I still have to corrige the series resistance of each LED to get the correct value of current flowing through the LEDs (approx 300mA <=> 1.8 ohm for the white LED, and I still have to chose my UV LED). The values displayed here are generic.

  • \$\begingroup\$ Why do you doubt that the simulation is accurate? Can you show us some waveforms? And no, you can't use an NMOS transistor for Q1 as you have shown...the parasitic diode is forward biased. \$\endgroup\$ Commented Apr 11, 2020 at 21:21
  • \$\begingroup\$ "I use three MOSFETs because the current drawn will be greater than 200 mA" - but you're using them in series so how will that help? \$\endgroup\$
    – Finbarr
    Commented Apr 11, 2020 at 21:35
  • \$\begingroup\$ So do you mean that MOSFET in series can't transmit the upstream current properly? I am quite unexperienced at using transistor so any explanation would help me. Also, do you think that a P-channel MOSFET would be a good replacement to Q1? \$\endgroup\$
    – Antoine D
    Commented Apr 11, 2020 at 21:47
  • \$\begingroup\$ @Finbarr the MOSFETs are there because the current is more than GPIO can handle. There are three because he wants to switch the current in three places, not to handle more current than a single MOSFET can deal with. \$\endgroup\$ Commented Nov 29, 2021 at 11:39

2 Answers 2


Since your PIC has at least two PWM outputs, the simplest solution would be to use one NMOS per LED, each driven by a separate PWM output. Then simply enable the output you want in software. This uses the same number of pins on the connector too.

If that's not possible, it would be better to put the PWM NMOS on the low side.

enter image description here


This time you got the top MOSFET the right way round. and the circuit looks good. As you've noticed there's not much headroom - the voltage available is barely sufficient.

I would be looking for a way to use only the bottom MOSFET and somehow mix the PWM in with the select signal. this would also allow a higher voltage supply for the LEDs.


simulate this circuit – Schematic created using CircuitLab

if you go with 5V for ther LEDs 74HC02 can handle the 3V logic signal and output 5V to drive MOSFET harder (if powered from 5v). else use a 3.3V nor gate chip


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.