I am using a mosfet and an Arduino and I want to control the Source-Drain current of the mosfet by adjusting PWM to the Gate.

If I apply zero value to the PWM, the current doesn't stop (I checked the PWM output with voltmeter and it's zero volts). When I manually connect the gate to the ground with a wire, the current stops.

How can I stop the current with PWM output that connected to the gate?

Here's my circuit. I common all the grounds with wire and put mosfet and hall effect sensor on two separate breadboard.

Also, I'm powering the Arduino with a printer cable that's connected to my laptop.


  • 1
    \$\begingroup\$ Show the schematic and a clear picture of the physical implementation. It's possible you've damaged or miswired the MOSFET. Also explain how you are measuring the current. Also try configuring the pin as a simple output driven low, not a PWM and see if you get a different result. \$\endgroup\$ Aug 5, 2019 at 17:19
  • 1
    \$\begingroup\$ .... and don't forget to clearly show how and where power and Arduino grounds are connect \$\endgroup\$
    – carloc
    Aug 5, 2019 at 18:02
  • 3
    \$\begingroup\$ Connect a resistor - maybe 10k- between gate and source. That'll fix your problem. \$\endgroup\$ Aug 5, 2019 at 18:27
  • 2
    \$\begingroup\$ With PWM set to zero, measure voltage from Arduino +5V to the MOSFET Gate. What do you get? \$\endgroup\$ Aug 5, 2019 at 19:48
  • 2
    \$\begingroup\$ The glaring problem with your circuit is that you've interchanged the proper positions of the inductive load and the MOSFET. Q1's source needs to be grounded, directly or at most through a small sense resistor. Beware that some cheap bench supplies have truly nasty turn on and turn off behavior with huge voltage spikes. Plus a MOSFET sitting on top of an inductor could easily result in exceeding the gate oxide's quite low maximum voltage rating. You should rebuild the circuit with the FET and load in proper positions, a reverse catch diode across the load, and you may need a new FET. \$\endgroup\$ Aug 6, 2019 at 15:28

2 Answers 2


the source of your MOS-FET needs to be connected to the reference of the 5V supply of the arduino, your schematic does not show this connection.

without it the gate voltage is floating so it will be very unlikely to ensure turn off while floating.

You always apply voltage as a differential so a single connection, the gate needs the output, but also the source needs to be connected to the 5V reference.

Sadly, this is not a good design you do not want the reference of the Arduino to have an inductor leading to ground right after and not be connected to ground.

I have a couple ideas from the top of my head.

Re-design the circuit so the source goes to ground and you can connect the Arduino reference to source also

use a DC-DC converter to isolate the arduino from your 5V power line then there is no issue with connecting the source to the 5V reference.


You may try this ?

Link : Potentiometer as MOSFET control + Arduino


Attach Image enter image description here

after success, you may replace potentiometer with PWM.

Reference Link :


  • \$\begingroup\$ Welcome at electronics.SX. To give a good answer here you should probably replace the nice colorful picture with a real circuit diagram to make it easy to understand the circuit. Also you should eleborate a little bit more why you suggest this circuit. Link-only-answers are likely to be deleted due to there limited use for this platform. \$\endgroup\$
    – jusaca
    Apr 8, 2020 at 7:52
  • \$\begingroup\$ Welcome as a general rule i would suggest when publishing an answer to anything, to read what you write and ask yourself whether you would understand it if you hadn't written it yourself, also to check your schematics (even if they are fritzing ones) if you look at the transistor (or regulator) at the bottom left you will see that it is floating \$\endgroup\$
    – diegogmx
    Apr 8, 2020 at 23:40

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.