starter kit/Switching/12. Switch with a MOSFET
Switching · 12 of 16

Switch with a MOSFET

A MOSFET is a switch that is closed by a voltage rather than a current. With one 2N7000, the button from the last circuit and a pull-down, the LED comes on when the gate reaches the rail, and nothing flows into the gate to keep it there.

You need the transistor circuit working, one 2N7000, one 1 kΩ and one 10 kΩ resistor, a 220 Ω resistor, a red LED and the button. The button, the LED and the 220 Ω are the ones you have already used. This circuit replaces the S8050 with the MOSFET and the 4.7 kΩ base resistor with a 1 kΩ at the gate.

A switch closed by a voltage

The S8050 is closed by a current: a little of it has to flow into the base, all the time, for as long as the switch is on. A MOSFET is closed by a voltage. Its gate is a metal plate separated from the silicon underneath by a layer of glass. Put a voltage on the plate and its electric field pulls electrons into the silicon beneath it, and a conducting channel forms between the other two legs, the source and the drain. Take the voltage away and the channel goes.

Because the plate is insulated, no current flows into it once it has charged. Holding a MOSFET on costs nothing.

Find the legs

The 2N7000 is a small black plastic body with a flat face and three legs, the same case as the S8050. With the flat face towards you and the legs pointing down, the order in Vishay's sheet for the 2N7000 is source, gate, drain from left to right. Some makers print the drain first, so check yours with the meter before you plug it in.

Which leg is which
Look at
Leg 1
source
Leg 2
gate
Leg 3
drain
Flat face towards you, legs down: source, gate, drain, left to right. That is the order in Vishay's sheet for the 2N7000, and the usual one. Some makers print the drain first, so confirm it with the meter before you wire it.

The gate is insulated from everything, so the meter reads open to it in every direction. The only thing a meter finds in a MOSFET is the diode that is part of the device between the source and the drain: with the red lead on the source it reads a diode drop, and open the other way. That identifies the gate for certain, as the one leg that reads open to both others, and it tells you which of the other two is the source: the one the red lead is on when the diode conducts.

Build it

The button joins the plus rail to a node. A 10 kΩ pull-down holds that node at the minus rail when the button is open, exactly as in the button circuit. The 1 kΩ runs from the node to the gate. The LED and its 220 Ω sit on the drain, and the source goes to the minus rail.

Circuit four, on the breadboard
The button
Gate voltage
0.0 V
Through the LED
0 mA
Drain to source
4.8 V
Across the 1 kΩ
about 0 V
Released: the pull-down holds the node, and through the 1 kΩ the gate, at 0 V. The channel is closed, the LED's loop has a gap at the MOSFET, and the whole rail sits across it.

The button is wired from opposite corners, as before. The 10 kΩ runs from the button's output strip to the minus rail. The 1 kΩ runs from the same strip to the strip the middle leg of the MOSFET is in. The left leg, the source, goes to the minus rail with a wire. The LED's short leg goes to the strip of the right leg, the drain, and the 220 Ω runs from the LED's long leg to the plus rail.

Look at what is missing. In the transistor circuit the base resistor set a current. Here the 1 kΩ sets nothing, because there is no current in it: the gate and the node are at the same voltage, whatever the resistor's value. Without the pull-down, the node and the gate float when the button is open, and a floating gate is the most common mistake with a MOSFET. It holds whatever charge it last had, or picks up whatever a nearby finger or wire puts on it, so the LED comes on and goes off for no reason.

What the gate voltage does

A MOSFET does not switch on at a sharp voltage. Below a threshold the channel is closed. Above it, the channel opens, and the further above, the lower its resistance. The threshold is not a fixed number. Vishay's sheet for the 2N7000 gives it as 0.8 V at the lowest, 2.1 V typically and 3 V at the highest, so two parts from the same box can behave differently.

What the gate voltage does
Power module
This 2N7000's threshold (the datasheet's three)
Gate voltage4.8 V
Through the LED
12 mA
Drain to source
0.05 V
Channel
4.0 Ω
Well on: the channel is about 4.0 Ω, so the 220 Ω sets the current at about 12 mA and the channel has about 0.05 V across it. The curve is far above the dashed line: the MOSFET could carry much more than this LED asks.

The 2N7000 is not a logic-level part: its on-resistance is specified at gate voltages of 4.5 V and above, about 4.5 Ω typically and 5.3 Ω at the most at 4.5 V, and 2.4 Ω typically at 10 V. On the 5 V side, with about 4.8 V on the gate, the channel is about 4 Ω. That is tiny beside the 220 Ω in the LED's loop, so the resistor sets the current and the MOSFET is a closed switch.

Move to the 3.3 V side and the picture changes. The gate has only 3.3 V. A typical part is still about 9 Ω, but a part whose threshold is near the 3 V maximum has a channel of tens of ohms and is only just on. It still lights an LED, because the LED's branch asks for so little, and it would not switch a bigger load. The figure's channel is an illustrative model scaled to the datasheet's 4.5 V figure and is good to within a factor of about two away from it.

In order

Press to light, in order
Gate voltage
0.0 V
Into the gate
0 mA
Through the LED
0 µA
The button is released. The pull-down holds the node and the gate at 0 V. The channel is closed and the LED, in a loop with a gap at the MOSFET, is dark.

The button carries only the half milliamp that runs down the pull-down. The gate takes a brief trickle of charge to rise, a few nanoseconds' worth, and then nothing. This is the idea behind a MOSFET: a voltage, not a current, decides.

Against the S8050

Neither part is better. They are good at different things.

Transistor against MOSFET
The load being switched
For a 12 mA LED either part is fine. The transistor costs the button about 0.8 mA to hold on, the MOSFET costs it nothing, and both leave the LED's own 220 Ω to set the current.

Handle it gently

The glass under the gate is only nanometres thick, and the gate is rated for about 20 V. A spark of static is far more than that. The risk at a hobby bench is small and the part is cheap, but touch something metal before you pick one up, do not slide it across a carpet, and do not leave its legs unconnected while you build around it. Once it is in a circuit with a pull-down it is far safer than loose in your hand.

Measure

Set the meter to DC volts. Put the black lead on the minus rail.

  • Gate, button released: 0.00 V. This is the pull-down at work. If it wanders, the pull-down is not connected.
  • Gate, button pressed: about 4.8 V, the same as the rail. The gate is at the rail because it draws no current, so nothing is lost across the resistor.
  • Across the 1 kΩ, pressed: a few millivolts at the most. This is the reading that shows the gate draws no current. The 2N7000's gate leakage is under 10 nA by the datasheet, which across 1 kΩ is 0.01 mV. Any reading you see is the meter and the wires, not the gate.
  • Drain to source, pressed: about 0.05 V. The channel is a few ohms and the current is about 12 mA, so it drops a few hundredths of a volt. Anything under 0.3 V is a switch that is closed.
  • Drain to source, released: about 4.8 V, because no current flows and the MOSFET takes the whole rail.
  • Across the 220 Ω, pressed: about 2.75 V, the rail less the LED's 2 V and the channel's 0.05 V. Divide by 220 Ω for about 12.5 mA.

On the 3.3 V side, the gate reads 3.3 V when pressed, the drain-source voltage is still about 0.05 V with a typical part, and the current across the 220 Ω is about 5.7 mA: the LED is dimmer because there is less supply, not because the MOSFET is failing. A part with a high threshold reads a larger drain-source voltage, up to about 0.2 V, and a smaller current, about 5 mA.

Where the limit is

The 2N7000 is rated for 60 V between drain and source and about 200 mA continuously at 25 °C, by Vishay's sheet, and for 20 V on the gate. A single LED at 12 mA is far inside all three. The next circuits stop switching and start sensing: two of the parts in the kit change their resistance with the world, and a divider turns that change into a voltage you can read.

When it does not work

The LED never lights when I press the button.

Press and measure from the gate to the minus rail: it should read about 4.8 V. If it reads 0 V, the button or the 1 kΩ is not connected. If the gate is at the rail but the LED is dark, the load side is wrong: the LED backwards, a missing 220 Ω, or the legs in the wrong order. Check the legs with the meter's diode mode first.

The LED is on, or flickers, when nobody is pressing.

The gate is floating. A gate connected to nothing is a tiny capacitor with no way to discharge, and a finger near it, or a nearby wire, can charge it past the threshold. The 10 kΩ pull-down must run from the node, which the gate resistor feeds, to the minus rail. With it in, the gate reads 0.00 V when the button is released.

The LED is dim, and the MOSFET is warm.

Measure the gate with the button pressed. On the 5 V side it should read about 4.8 V. On the 3.3 V side the gate is only 3.3 V, and a 2N7000 with a threshold near its 3 V maximum is barely switched on. Move to the 5 V side, or use the S8050 from the last circuit, which needs only 0.65 V on its base.

Do I need the 1 kΩ between the node and the gate?

The circuit works without it. It is there because a gate is a small capacitor, and wires into one can ring when the voltage changes fast. A few hundred ohms to a kilohm in front of the gate is the habit that keeps that from mattering. It costs nothing here, because no current flows through it to hold the gate.

Can I use it to switch a motor or a relay?

Only a small one. The 2N7000 is rated for about 200 mA continuously, and at 4.8 V on the gate its channel is a few ohms, so near its limit it drops most of a volt and gets warm. It switches an LED or a small buzzer well. For anything that takes more than about 100 mA, use a part made for it, or the S8050 for loads up to a few hundred milliamps.

Where this goes next

Two parts in the kit change their resistance with the world around them. The first answers to light.

A light sensor and a divider →

Edit this page — content/books/estkit/switch-with-a-mosfet.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

Ask a question ↗

Electronics Starter Kit, Breadboard, Power Module and Components

Loading discussions…

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum →