I'm currently working on a circuit that later should control a pump. For the debugging I replaced the pump with a LED and ramp up the signal every second (0>25>75>100%). In the end the PWM signal of the Arduino should control the LED/pump. But the LED is fully on (maybe a bit flickering) enter image description here I tested following things:

Disconnect the arduino pin >> LED still on (shouldn't it be off?)

Disconnect the Vin >> LED is off (OK)

Connect the arduino pin directly to the gate >> LED full on (should follow the ramp)

Remove R2 >> still got the problem.

Switched the MOSFET >> still got the problem (=part is not broken or both).

Connected the LED directly to the Arduino pin >> works as it should.

I got the sketch (and part list) for the circuit from a tutorial, but unfortunately can't find it anymore online.

At this point I have no more ideas what the reason could be, I don't think its the optocoupler. Maybe there is something fundamentally wrong with the circuit... Can somebody spot the problem?

  • 4
    \$\begingroup\$ Are you sure the MOSFET is hooked up right? Seems reversed to me. \$\endgroup\$
    – Yiannis
    Sep 13, 2021 at 23:41
  • 1
    \$\begingroup\$ duckduckgo.com/?q=mosfet+body+diode&ia=web \$\endgroup\$
    – jsotola
    Sep 14, 2021 at 1:28
  • 1
    \$\begingroup\$ Your MOSFET is upside down. How come you aren’t using the big standard low side N-channel MOSFET configuration? You need a freewheeling diode across your motor. \$\endgroup\$
    – winny
    Sep 14, 2021 at 6:56
  • \$\begingroup\$ You forgot "measure the MOSFET gate voltage" or indeed any voltages in your debugging steps. Also as Winny says, because the PMOS FET is upside down, its body diode conducts whatever else you do. \$\endgroup\$
    – user16324
    Sep 14, 2021 at 12:31

2 Answers 2


The MOSFET is behaving exactly as it should! According to your schematic it is wired backwards - i.e. pins 2 & 3 swapped. Fix that and it should work as you expect.


The answer are already in your schematic. Pretty common mistake which has been answered dozens of time even here, on StackExchange.

Look at your MOSFET Q1 symbol on the scheme. That diode symbol on the right does really exist. It's called a "body diode" and is a kind of manufacturing process. It's just how FET are made. So that is why the P-channel MOSFET are usually connected in reversed direction (compared to your variant). I.e. current flows from source to drain in real switching applications. Also a reason why you see negative numbers in the datasheets of P-channel MOSFETs, as it mentions drain-source instead.

Just reverse drain with the source and should work as you expect.


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.