Why is this MOSFET (BS170) not turning the LED completely OFF and then ON?

PIN2 of Arduino is set to HIGH for 100ms then LOW for 100ms. The LED does blink by getting brighter and then dimmer, but not ON and then OFF.

Green wire is connected to PIN2.

arduino and mosfet

  • \$\begingroup\$ And at 500ms on and off, what does it look like then? Also, add a resistor between LED and 5V, about 330Ω for your average red LED. \$\endgroup\$
    – ocrdu
    Commented Nov 9, 2020 at 17:21
  • \$\begingroup\$ At 500ms it's still the same but slower. The resistor made the LED dimmer. \$\endgroup\$ Commented Nov 9, 2020 at 17:31
  • \$\begingroup\$ It seems that your "OFF" is not actually "OFF" i.e (0V). Remove the MOSFET and measure the output voltage of the pin when it is set to LOW. The Vgs for that MOSFET is typically 2V with a minimum of 0.8V. So they might still be some leakage from the pin with it is set LOW, that causing the gate to "open" and allowing some current to flow from the drain to the source. \$\endgroup\$
    – JoeyB
    Commented Nov 12, 2020 at 22:15

2 Answers 2


You have the MOSFET backwards with the drain and source interchanged.

Likely when "off" you are still getting a path through the body diode in series with the LED, and when "on" you bypass that causing the LED to be brighter as the structure is symmetric enough that it can work "a bit" in the opposite direction.

  • \$\begingroup\$ I switched the source and drain as you told, but the LED still does not go completely off. Just bright and then dimmer as before. \$\endgroup\$ Commented Nov 9, 2020 at 17:33
  • \$\begingroup\$ Try disconnecting the gate from the Arduino entirely. It's also quite possible at this point that you have damaged the FET. A typical indicator LED you could just drive directly with a suitable current limit resistor. Extremely bright ones are going to need a bit more consideration than you are giving here to power and current limit - just an FET won't do it. \$\endgroup\$ Commented Nov 9, 2020 at 17:39
  • \$\begingroup\$ After disconnecting the gate from Arduino, the LED went OFF then ON and it is staying ON. I can get it to turn OFF by tapping the end of the wire that was connected to PIN2 with my finger. Replacing the MOSFET with a fresh one did not change anything. \$\endgroup\$ Commented Nov 9, 2020 at 17:45

I've gotten a lot of use out of BS170s and I hope you will too.

Some things to try:

  1. Measure the OFF resistance. Should be > 50KOhm
  2. Measure the ON resisitance. Should definitely be < 100 Ohm (datasheet says 5 Ohm)
  3. Do continuity check from source to drain to test body diode. Should show connected
  4. Do continuity check from drain to source to test body diode. Should show not connected.
  5. Measure resistance between the gate and drain, and between gate and source. Should be very high. If any of these tests fail, your component is bad. Aand be careful if you disconnect the FET to test OFF resistance. If you don't discharge the gate, it's still ON. Ideally, test ON resistance with a wire from 5V to the gate.
  6. Make sure the source terminal (pin 3) is connected to ground. If you flip it, the body diode will allow current to flow and your LED may appear dimly lit.
  7. Test the circuit without the arduino pin, by connecting the gate to 5V, then to ground.
  8. Test your digital pin both sourcing and sinking current. In order to turn off the FET, the pin must be able to let charge exit the gate, flowing into the GPIO pin and then to ground. You can test it by powering an LED, as the high side and then as the low side. If it fails either, your GPIO pin is bad. If this is a regular problem, consider adding a resistor to the gate terminal. See the web for plenty of examples.
  • \$\begingroup\$ Thank you for a great in depth answer, but I still can't get it to work... All the test results seem to match up, but I still can't get it turn off and then on. Would you be willing to help me out in a video call? \$\endgroup\$ Commented Nov 12, 2020 at 18:17
  • \$\begingroup\$ Measure the voltage at the drain with your circuit operating. Does it go to 5V when the digital pin is LOW? And does it go to 0V when the digital pin is HIGH? Passing this test means your FET is working fine. If it never goes to 5V, your LED might be burned out or bad connection. \$\endgroup\$ Commented Nov 13, 2020 at 0:57
  • \$\begingroup\$ While measuring around with a multimeter, I came across that if I measure the voltage between ground and PIN2 of Arduino the circuit works. If I remove the probes from either pin it stops working. Shorting the pins with a piece of metal just turns the LED off until I unshort them. Here's a video: ufile.io/7x86424e \$\endgroup\$ Commented Nov 19, 2020 at 10:26
  • \$\begingroup\$ Here's a video, so you don't have to download it: vimeo.com/481178290 \$\endgroup\$ Commented Nov 19, 2020 at 11: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.