Using a MOSFET as a switch is the standard method for controlling high-current loads like motors, LED strips, and heaters with Arduino’s low-current digital outputs. A single Arduino pin (max 40mA) cannot directly drive a 2A motor or a 5A LED strip, but a logic-level MOSFET bridges this gap efficiently. This tutorial covers N-channel and P-channel configurations, proper gate driving, PWM for speed/brightness control, and common mistakes to avoid.
Table of Contents
- Why Use a MOSFET Instead of a Relay
- N-Channel MOSFET Low-Side Switching
- P-Channel MOSFET High-Side Switching
- Logic-Level MOSFETs for Arduino
- PWM Motor and LED Control
- Protection Circuits
- Frequently Asked Questions
- Conclusion
Why Use a MOSFET Instead of a Relay
MOSFETs switch in microseconds (relays take milliseconds), produce no clicking noise, have no mechanical wear, support PWM for variable speed/brightness control, and are more compact. The only advantage of relays is electrical isolation and the ability to switch AC mains. For DC loads under 30V, MOSFETs are almost always the better choice.
N-Channel MOSFET Low-Side Switching
The most common configuration places an N-channel MOSFET between the load and ground (low-side switching). The load connects from the positive supply to the MOSFET drain, and the MOSFET source connects to ground.
// N-Channel MOSFET Low-Side Switch
// Arduino Pin D9 → 220Ω resistor → MOSFET Gate
// Also add 10kΩ pull-down: Gate to GND (ensures OFF when Arduino resets)
// Load (+) → 12V supply (+)
// Load (-) → MOSFET Drain
// MOSFET Source → GND (shared with Arduino GND)
// 12V supply (-) → GND (shared with Arduino GND)
int mosfetPin = 9; // PWM capable
void setup() {
pinMode(mosfetPin, OUTPUT);
}
void loop() {
// Full ON
digitalWrite(mosfetPin, HIGH);
delay(2000);
// 50% PWM (half speed/brightness)
analogWrite(mosfetPin, 128);
delay(2000);
// OFF
digitalWrite(mosfetPin, LOW);
delay(2000);
}
P-Channel MOSFET High-Side Switching
P-channel MOSFETs switch the positive supply (high-side), keeping the load ground intact. This is important when the load needs a common ground reference (e.g., WS2812 LED strips). However, driving P-channel gates from 3.3V/5V Arduino requires an NPN transistor level shifter when the supply exceeds 5V.
Logic-Level MOSFETs for Arduino
Standard MOSFETs need 10V gate voltage for full saturation. Logic-level MOSFETs are designed to fully turn on at 3.3-5V gate voltage. Popular choices available in India:
| MOSFET | Type | Vgs(th) | Rds(on) @ 4.5V | Max Current |
|---|---|---|---|---|
| IRLZ44N | N-Channel | 1-2V | 22mΩ | 47A |
| IRL540N | N-Channel | 1-2V | 44mΩ | 36A |
| IRLB8721 | N-Channel | 1.35-2.35V | 8.7mΩ | 62A |
| IRF3205 | N-Channel | 2-4V | 8mΩ | 110A |
The IRLZ44N and IRLB8721 are the best choices for 5V Arduino logic. For 3.3V ESP32, only the IRLB8721 reliably fully saturates.
PWM Motor and LED Control
Arduino’s analogWrite() generates PWM at approximately 490 Hz (pins 3, 9, 10, 11) or 976 Hz (pins 5, 6). This frequency is adequate for motor speed control and LED dimming. For large motors, use a higher PWM frequency to reduce audible whine (requires Timer register manipulation).
Protection Circuits
- Gate resistor (220Ω): Limits current from the Arduino pin during gate charging
- Pull-down resistor (10kΩ): Ensures MOSFET stays OFF during Arduino boot/reset
- Flyback diode (1N4007): Essential across inductive loads (motors, solenoids, relays) to absorb voltage spikes
- Zener clamp (15V): Gate-to-source protection against static discharge
Frequently Asked Questions
Can I switch 12V LED strips with a 5V Arduino?
Yes. Use an N-channel logic-level MOSFET (IRLZ44N). Arduino 5V on the gate fully turns on the MOSFET, allowing 12V through the LED strip. The Arduino and LED strip share a common ground but have separate power supplies.
Why does my MOSFET get hot?
Two common causes: (1) The gate is not fully driven to saturation, so the MOSFET operates in its linear region (high Rds(on)). Ensure Vgs is at least 4.5V for logic-level types. (2) The current is too high for the MOSFET’s Rds(on). Power = I² x Rds(on). A 10A load through 22mΩ generates 2.2W of heat.
Can I use a MOSFET for AC loads?
Not directly. MOSFETs switch DC only. For AC loads (fans, lights on 230V mains), use a relay, TRIAC, or solid-state relay. Never attempt to switch mains voltage with a MOSFET unless you fully understand the circuit design and safety requirements.
What is the difference between MOSFET and BJT transistor for switching?
MOSFETs are voltage-driven (zero gate current in steady state) while BJTs are current-driven (continuous base current required). MOSFETs have lower on-resistance for high-current loads and are more efficient. Use MOSFETs for power switching; BJTs are still useful for signal-level switching and as MOSFET gate drivers.
Conclusion
MOSFETs are essential components for any Arduino project that needs to control high-current loads. Understanding the difference between N-channel and P-channel, logic-level vs standard, and proper gate driving ensures reliable, efficient power switching. Start with an IRLZ44N for 5V Arduino projects and you will find it handles most motor, LED, and solenoid control needs. Find MOSFETs, drivers, and Arduino boards at Zbotic.
Add comment