I have a problem I cannot figure out. I have this circuit which should control two LED strips either by wemos OR (methods are switched between by SPDT because I don't know automatic way) manually. Each "switch" should be able to turn on one or both leds.

Circuit details

Wemos uses two N-mosfets (irlml2502) to turn on/off leds. Manually I turn them on/off by SPDT switch. Circuit is powered by 12V adapter going to the LEDs and buck-converter to convert to 5V to power wemos. To separate LEDs powering I use Schottky diode SB540.


The problem is, when I use manual switch, it turns on both of the leds everytime. Also, the buck-converter´s power led is ON on that time but the IN- is not connected to anything.
Even when I connect ground to buck-converter IN- both ledstrips are turned ON.
As I understand it, ground to the mosfets should flow through buck-converter but it is flowing flowing somewhere else.

Only thing I can think of is that MOSFETs are allowing ground to flow "backwards" from drain to source and power the circuit through each other. Could you please help me fix the circuit?

Picture description

  • Circuit is not powered on pictures.
  • Purple colour shows the ground when I want to power single ledstrip.
  • Turquoise should power both strips.
  • Bold black wire upper-right is manual switch 2 and blue is manual switch 1. Curved blue on the right side is ground.
  • In schematics I ignore buck converter and wemos pins output to mosfets. One ledstrip two ledstrips clear circuit wemos buck converter


simulate this circuit – Schematic created using CircuitLab

  • \$\begingroup\$ Do mosfets have pull-downs? what is purpose of sb540 diode? get rid of It and try then (It allows for both leds power at the same time using switch) \$\endgroup\$
    – fifi_22
    Commented Oct 29, 2020 at 19:41
  • \$\begingroup\$ MOSFETs only have resistors from wemos to gate. Diode SB540 is dividing the circuit so that I can turn on only one led strip D2 or both of them D1+D2. Look at manual switch in schematic. Anyway, I removed diode and it is doing the same. \$\endgroup\$
    – GTessa
    Commented Oct 29, 2020 at 19:51
  • 2
    \$\begingroup\$ Check voltages from Gates to ground \$\endgroup\$
    – fifi_22
    Commented Oct 29, 2020 at 19:55
  • 4
    \$\begingroup\$ Why not connect the switches (SW2 and Manual) to a GPIO pin of the WeMos and then modify the programming? \$\endgroup\$ Commented Oct 29, 2020 at 20:02
  • \$\begingroup\$ @fifi_22 voltage on one MOSFET is always zero (when using manual switch) and the other one is either 0,3v or 0,7 depending on which manual branch is turned on. \$\endgroup\$
    – GTessa
    Commented Oct 29, 2020 at 20:25

1 Answer 1


There is a logical component "OR" that could be used. What is a logical gate? That is extensivly explained here https://en.wikipedia.org/wiki/Logic_gate


simulate this circuit – Schematic created using CircuitLab

Another solution is to add the switch to a GPIO on the WeMos and add code, example https://www.arduino.cc/en/Tutorial/BuiltInExamples/Button and if it is a push button please add some "debouncing" code as well, ref. https://www.arduino.cc/en/Tutorial/BuiltInExamples/Debounce

The debounce code is preventing the input from receiving several on/off when the button is pressed. Quote from the Arduino site, Pushbuttons often generate spurious open/close transitions when pressed, due to mechanical and physical issues: these transitions may be read as multiple presses in a very short time fooling the program

Note: Both above suggestions is making the SB540 obsolete.

  • \$\begingroup\$ thank for the explanation. I am very familiar with programming but in these "hardware-y" things I am beginner. I will take a look at OR gate. Also according to your previous comments I thought about removing SB540 and replacing SPDTs with pushbuttons connected to Wemos. As you suggested here. \$\endgroup\$
    – GTessa
    Commented Oct 30, 2020 at 13:12
  • 1
    \$\begingroup\$ I would not suggest the OR gate, the hardware path is hard to modify, programming is much simpler as you know ;-). There is a list of the common 74xx series (but I recommend the 74HC32, HC stands for High speed CMOS) en.wikipedia.org/wiki/List_of_7400-series_integrated_circuits , remember to ground the unused inputs since CMOS is sensitive for static charges. \$\endgroup\$ Commented Oct 30, 2020 at 13:55

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.