0
\$\begingroup\$

I need a simple diagram showing me how to switch 12V LEDs with a 2N7000 using an Arduino. My experience is moderate, but a simple diagram should get me started. To summarize I want to switch 12V with 3V using 2N7000 MOSFET, a LED strip, and an Arduino Uno. Also when I hook up the 12V LED strip's ground through the D and S of the 2N7000, it ligths up without anything connected to the Gate. That means it is open until it recieves what signal on the Gate?

I've tried this:

schematic

\$\endgroup\$
4
  • 2
    \$\begingroup\$ Looks like "I want you to do my work". What have you done yourself already? What are you trying to achieve in the end? A link to the relevant datasheet would be helpful too. \$\endgroup\$
    – user17592
    Commented Feb 21, 2013 at 9:46
  • \$\begingroup\$ I have googled and tried making the same setup myself, but have not got the same result, so i need a diagram for this exact scenario. also i have found setups that sometimes are opposite of eachother. What i am trying to achive is switching 12v LED strips (ground for R G and B), using and arduino. with this: fairchildsemi.com/ds/2N/2N7000.pdf \$\endgroup\$
    – Tom Sand
    Commented Feb 21, 2013 at 9:54
  • \$\begingroup\$ Post your schematic. \$\endgroup\$ Commented Feb 21, 2013 at 10:23
  • \$\begingroup\$ Alright, first drawing ever but here is the current setup: dl.dropbox.com/u/11643892/2N7000-1.png and my question is what do i have to supply to turn the LED's off ? \$\endgroup\$
    – Tom Sand
    Commented Feb 21, 2013 at 11:40

2 Answers 2

8
\$\begingroup\$

Using a 2N7000 is, as a first approximation, just like using a BJT to switch a load. The major differences are:

  1. the gate is (very) high impedance, so no resistor is required to limit the current, as a resistor would be needed in series with the base of a BJT

  2. the gate threshold of MOSFETS is typically higher than the 0.6V it takes to get a BJT to turn on

The datasheet will specify a gate threshold voltage \$V_{GS(th)}\$, which is the voltage at which the transistor begins to turn on. You want to apply more than this if you intend to operate the transistor as a switch. You also want to apply safely less than the specified absolute maximum gate-source voltage, which if exceeded, will destroy the device. I happen to know off the top of my head that 5V is a good gate voltage for 2N7000, which is convienent because you can connect it directly to your Arduino.

What you are missing, it seems, is how to use a transistor as a switch. Searching for "transistor switch" turns up a few million tutorials, but here's the brief version:

schematic

Applying 0V to the input makes the transistors appear like an open switch, and your load (represented by resistors) is effectively disconnected from the power supply. Applying a higher voltage (whatever voltage is used for the logic in your circuit, usually 5V in the case of Arduino) turns the transistors on, and they look like a closed switch, effectively connecting your load between Vcc and ground.

\$\endgroup\$
6
  • \$\begingroup\$ What i dont understand is why the 2N7000 is acting like a closed switch whn i just connect the Drain snd Source, and dont put anything on the gate. should it not then act like and open switch ? \$\endgroup\$
    – Tom Sand
    Commented Feb 21, 2013 at 12:19
  • 2
    \$\begingroup\$ @TomSand because the gate is so high impedance, even just the noise from your finger can be enough to turn it on. Essentially, the gate and drain make a capacitor (if you look at the schematic symbol, you can see the resemblance), and even if you disconnect it, it can maintain its charge and keep the transistor on. This is, interestingly, the basis for flash memory. It's common to put a highish value resistor (10k, perhaps) from the gate to ground in the circuit to be sure any residual gate voltage can go to ground. \$\endgroup\$
    – Phil Frost
    Commented Feb 21, 2013 at 12:24
  • 1
    \$\begingroup\$ @TomSand I'd suggest building this circuit on a breadboard, then try turning the transistor on by jumpering the gate to +5V. Then remove the jumper. Then jumper it to ground. Then remove the jumper. Then try licking your fingers and touching the gate. \$\endgroup\$
    – Phil Frost
    Commented Feb 21, 2013 at 12:27
  • \$\begingroup\$ @TomSand also, I suggest you read electronics.stackexchange.com/questions/28251/… \$\endgroup\$
    – Phil Frost
    Commented Feb 21, 2013 at 12:58
  • \$\begingroup\$ Well, this is now up and running with arduino =) fading in and out nicely =) But i am unsure of how much load (Watts) i can run on the 12V using the 2N7000 ? i can not see in the datasheet. (www1.elfa.se/data1/wwwroot/assets/datasheets/…) \$\endgroup\$
    – Tom Sand
    Commented Feb 21, 2013 at 17:51
0
\$\begingroup\$

Below is exactly how the circuit should look. R1 should be chosen to get the desired LED current. D1 can be a single LED, or multiple LEDs in series (not in parallel!).

R2 is a pull-down resistor on M1's gate so that when the Arduino is initializing, the LED will remain OFF until the output pin is driven high for the first time. R2's value is not critical, anything in the range between 10kΩ and 1MΩ will work.

It is important that the 12V supply is attached directly to the source of M1 and to the top of R1. The source of M1 is then a star grounding point where the 12V supply's negative side connects with the digital ground of the circuit.

schematic

simulate this circuit – Schematic created using CircuitLab

The LED turns on when the GPIO is at high logic level. E.g. digitalWrite(ledPin, HIGH) will turn the LED on, and digitalWrite(ledPin, LOW) will turn it OFF.

I think I was expecting the 2N7000 to act opposite.

The pin state is determined by your code, so which way the MOSFET acts is of no concern. You can easily adapt the software to provide the logic level needed to turn the LED on and off no matter which way M1 acts. As shown, a HIGH level turns the LED on. If you want a LOW level to turn the LED on, just write a function that inverts the signal:

constexpr const int8_t ledPin = ...;

inline void setLedState(int8_t state)
{
  if (state==HIGH) digitalWrite(ledPin, LOW); else digitalWrite(ledPin, HIGH);
}

Addressing some of the comments:

The link to the solution diagram is no longer valid (dl.dropbox.com/u/11643892/2N7000-2.png)

That's why it's a bad idea to use anything other than the image hosting built into this site (at the moment it's StackExchange's imgur account).

This is the most logical and intelligent answer I have seen how this particular 2N7000 mosfet works.

All N-mosfets work the same really. So nothing you read here has much to do with the particular 2N7000 mosfet.

The only N-MOS specs matter here are the threshold voltage and channel current capacity. If the threshold voltage is higher than about 2V, then the 3.3V logic output of an Arduino won't be high enough to fully turn the N-MOS on. In that case, you'd need to use a little voltage multiplier to step up the voltage from the Arudino - shown below.

The channel current capacity (maximum drain current) determines the maximum LED current allowed before the N-MOS will begin to sustain damage.


It is often the case that we may have an N-MOS device that has too high a threshold voltage to be controlled by logic levels directly. This is common with mosfets recovered from e-waste power supplies.

To cope with that, we need two things:

  1. A gate drive voltage generator that will supply 10-15V. The current needed is fairly low, so this doesn't need to be anything fancy.

  2. A level translator that will take the 3.3V logic level output and translate it to the 10-15V voltage from the generator above.

To get a 10-15V supply, we take a square wave output from an Arudino and pass it through a voltage multiplier:

schematic

simulate this circuit

Schottky diodes an be almost any type rated for 100mA average forward current. The 10kΩ load is just for illustration, an actual gate load will be much higher impedance as low as the PWM frequency (if any) is kept low, say 1kHz or so.

To translate the Arduino 3.3V GPIO output to this higher level, use CD4504 or CD40109 for example.

  • CD4504: pin 8 is GND, pin 1 - 3.3V, pin 16 - output of the voltage multiplier, pin 13 connect to pin 16, pins 3,5,7,9,11,14 are inputs and pins 2,4,6,10,12,15 are their respective outputs; the logic function is an inverter.

  • CD40109: pin 8 is GND, pin 1 - 3.3V, pin 16 - output of the voltage multiplier, pins 2,7,9,15 connect to pin 1, pins 3,6,10,14 are inputs and pins 4,5,11,13 are their respective outputs; the logic function is a logic buffer.

\$\endgroup\$

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.