Switching an N-channel MOSFET - am I missing something?

I’m trying to control some LED lights, switch on or off. I have an N channel MOSFET and I figured I’d just attach the gate to say pin 9 on the Imp and set it’s value to HIGH but nothing seems to happen. I can switch an LED on or off no problem. I tried the MOSFET on an Arduino and that works fine, sending a high or low value to a pin.

Any idea what I’m doing wrong?


The imp works at 3.3V versus 5 for many Arduino boards. Also, the Imp can only source or sink 4mA per pin. You need to pay attention to the data sheet of your MOSFET and the voltage required.

check this page

for more info. It seems to suggest using IRLZ44

This is the one I’m using http://www.sparkfun.com/datasheets/Components/General/RFP30N06LE.pdf

Have no idea what those numbers or diagrams mean! I guess I need to start learning about electronics.

My guess is that you’ve got the FET on the wrong side of the load.

The reason you’re seeing it work with a single LED is likely this: you have the source of the FET wired to the anode of the LED, and the cathode of the LED to ground. This is raising Vsource to the voltage drop of the LED - maybe 1.8v - and so the imp is managing to get Vgs just high enough (3.3 - 1.8v = 1.5v) to turn the fet on a bit, letting current flow. When you try this with your other lights, the imp can’t get the gate high enough to turn the FET on, but the arduino can as it’s 5v.

You should have the source of the FET connected to ground, the gate connected to the imp pin, and the drain of the FET going to the negative side of the LEDs, with the LED supply going to the positive side of the LEDs.

On an N channel fet, to turn it on you need to ensure that Vgs (the difference in voltage from the gate to the source) is greater than Vgs(th) - the threshold. The part you’re using there has a Vgs(th) of maximum 2v, so it’s fine for the imp 3.3v pins. As the source of the FET is connected directly to ground, the imp will always be able to drive the gate to 3.3v above source and hence always turn the FET on.

The great thing about this (called “low side switching”) is that you can switch voltages much higher than the imp could tolerate, up to the rating of the FET. eg you could have a 24v load controlled by the imp’s 3.3v, as the gate is totally isolated from the current flowing between the drain and source of the FET.

Thanks Hugo - that worked!