Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsYes—you can use a microcontroller’s PWM output to control a transistor, but the GPIO pin should provide only the control signal. The load gets power from a separate supply, while an N-channel logic-level MOSFET usually switches that power on the low side. Connect the grounds, add a gate resistor and pulldown, and place a correctly oriented flyback diode across motors, solenoids, relays and other inductive loads.
What “PWM through a transistor” actually means
Pulse-width modulation (PWM) is a digital waveform that repeatedly switches between ON and OFF. Its duty cycle is the fraction of each period spent ON:
D = TON / T
At 25% duty cycle, the switch is ON for about one quarter of every cycle. The transistor is not supposed to pass one quarter of the current continuously; it should be nearly fully ON or fully OFF. That minimizes power lost in the transistor.
The load’s result is load-dependent. A heater’s average temperature, an LED’s perceived brightness, a solenoid’s force and a motor’s speed will not all vary linearly with duty cycle.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →#1 Best Overall
- EEEEE 10 Values 70 Pc MOSFET transistor kit with Normal NMOS, Logic, High current and PMOS
- NMOS IRFZ44N IRF530N IRF540N IRF640N IRF740 IRF840
- Logic Level RFP30N06LE 2N7000
- High Current IRF3205
- PMOS IRF9540
The standard low-side MOSFET circuit
Use an external supply sized for the load. Place the load between the positive rail and the drain of an N-channel MOSFET; connect the source to the supply negative. Connect that negative rail to the microcontroller’s GND so the PWM signal has a reference.
External supply + ---- LOAD ----+---- Drain N-MOSFET
|
+----|<|----+
diode |
External supply - ---------------- Source---+---- MCU GND
MCU PWM pin ---- gate resistor ---- Gate
Gate pulldown (about 10 kΩ) to Source/GND
For an inductive load, the diode is parallel with the load: its cathode (marked end) goes to the positive supply and its anode goes to the drain/load-switching node. SparkFun shows this arrangement for motors because it absorbs the voltage spike produced when winding current is interrupted: SparkFun motor wiring guide.
Supporting parts
- Gate series resistor: a small value from tens to a few hundred ohms limits transient gate current and ringing. Choose it with switching speed, wiring and EMI in mind.
- Gate pulldown: approximately 10 kΩ is a common starting point to keep the MOSFET off while the MCU resets or is unplugged.
- Flyback diode: required for inductive loads unless equivalent protection is already integrated.
- Decoupling: place ceramic and bulk capacitors close to the switching circuit and load supply.
- Fuse or current limiting: appropriate when the supply can deliver dangerous fault current.
A gate resistor or pulldown is prudent design practice, particularly with long wires, exposed connectors or fast PWM; neither is a universal substitute for a proper driver.
Choosing a MOSFET or BJT
| Requirement | Usually preferable | Reason and qualification |
|---|---|---|
| Small, low-current load | Small logic-level MOSFET or NPN BJT | Either can work when voltage, current and heat are checked. |
| 3.3 V GPIO switching a 12 V load | Logic-level N-channel MOSFET | Verify RDS(on) at 3.3 V, not merely at 10 V. |
| Motor, solenoid or relay | N-channel MOSFET plus flyback clamp | Use a driver board or IC when current, speed or protection demands exceed a GPIO circuit. |
| Reverse motor direction | H-bridge or motor-driver IC | A single transistor is one-direction switching only. |
| Ground-referenced load | High-side switch | Use a P-channel device, PNP, high-side driver or load-switch IC. |
| Current-regulated LED | Constant-current LED driver | A transistor alone does not regulate LED current safely. |
MOSFET selection
Read the datasheet for:
RDS(on)specified at your actual gate voltage (3.3 V or 5 V);- drain-source voltage above the supply and expected transients;
- continuous and pulsed current under your package and board conditions;
- total gate charge suitable for the PWM frequency and available drive current;
- thermal resistance, package dissipation and temperature ratings.
Do not treat VGS(th) as the fully-on voltage. It only marks the start of conduction under a specified test condition. TI explains the distinction between logic-level operation and gate voltages used to specify low RDS(on) in its MOSFET gate-drive application note. For an example of the information to compare, TI’s CSD17310Q5A page lists a 30 V rating, logic-level designation, resistance at 4.5 V and gate-charge data; those figures apply only to that device and its test conditions.
Rank #2
- Minidodoca 31 values 580pcs High Quality BJT, Mosfets, Darlington Power Transistors Assortment Kit.
- Transistor Type: PNP & NPN
- Package form:TO-92
- Transistor Model: 2n7000 A42 BC327 BC337 BC517 BC546 BC547 BC548 BC549 BC550 BC556 BC557 BC559 2N2222A 2N2907 2N3904 2N3906 2N4401 2N5088 2N5401 2N5551 SS8550 SS8050 S8050 S8550 S9014 S9015 S9018 A733 A1015 C1815
- Equipped with tweezers for easy removal and insertion of products
BJT alternative
An NPN BJT is a low-side switch with the load on the collector, emitter at ground and the PWM pin driving the base through a resistor. Design for saturation using a forced beta, not an optimistic headline gain:
IB ≈ IC / forced_betaRBASE ≈ (VGPIO − VBE) / IB
Check the datasheet’s saturation voltage at the chosen forced beta and ensure base current stays within the MCU pin’s limits. A BJT needs continuous base current and dissipates power in its saturation voltage, so a suitable MOSFET is usually more efficient at higher load current. SparkFun’s Arduino motor example demonstrates a PWM pin driving an NPN through a resistor: SparkFun motor tutorial.
Arduino PWM code (with board-specific caveats)
On many classic Arduino cores, analogWrite() accepts an 8-bit value from 0 to 255, where 0 is always off and 255 is nominally always on:
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchRank #3
- BOJACK 10 Values MOSFET transistors Assortment Kit
- Product Name: MOSFET transistors
- Model: 10 Type: N-channel-( IRFZ44N IRF510N 520N IRF530N IRF540N IRF640N IRF740 IRF840 IRF3205),P-channel-(IRF9540)
- RoHS Compliant.
- Package Quantity: 50 Pcs (Each model 5 pcs), Packed in A Plastic Storage Case.
const int pwmPin = 9;
void setup() {
pinMode(pwmPin, OUTPUT);
}
void loop() {
analogWrite(pwmPin, 128); // approximately half-scale on classic 8-bit boards
}
A sweep can test the load:
for (int duty = 0; duty <= 255; duty++) {
analogWrite(pwmPin, duty);
delay(10);
}
for (int duty = 255; duty >= 0; duty--) {
analogWrite(pwmPin, duty);
delay(10);
}
Pin numbers, PWM-capable pins, resolution, frequency and timer behavior vary by Arduino board and core. Check the official board reference or use that platform’s timer/PWM API; pin 9 and the 0–255 scale are not universal. SparkFun documents the conventional range in its motor-circuit notes.
Flyback protection and inductive loads
A motor or coil stores energy in its magnetic field. When the transistor turns off, the inductor tries to keep current flowing and can generate a destructive voltage. The parallel diode provides a current path and clamps the switching node. Reverse polarity is dangerous: a diode with its cathode at the drain and anode at +V can short the supply when the transistor turns on.
Choose a diode for the load current, switching behavior and PWM frequency, and keep the loop physically short. For larger or faster systems, consider a Schottky diode, TVS or zener clamp, RC snubber or active clamp. A plain diode protects well but can make a solenoid release slowly; a higher-voltage clamp can speed release if the MOSFET’s voltage rating and clamp energy are adequate. Adafruit’s driver guidance covers kickback protection for motors, solenoids and high-power LEDs: Adafruit MOSFET driver overview.
Selecting PWM frequency
There is no universal best frequency. Lower frequencies reduce gate-drive and switching losses and are easy to observe, but may cause audible motor or coil noise, LED flicker or jerky motion. Higher frequencies can reduce audible artifacts and smooth current, but increase switching loss, gate-drive current, EMI and ringing.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #4
- 6 Values 50 Pc MOSFET transistor kit with NMOS IRFZ44N IRF530N IRF540N ,Logic Level RFP30N06LE 2N7000,PMOS IRF9540,just a perfect combination to meet your needs.
- Professional Certification:RoHS Compliant,High-efficiency processing capacity & Highmaterial & Durable performance .
- Widely Application:MOSFET Transistor are widely used in various fields such as Lighting Control,Power amplifiers,Motor drives,Electronic circuit protection power supplies, motor control, and Audio amplifier,etc..
- Package Quantity: 50 Pcs , Packed in A Plastic Storage Case. Each transistor model is clearly labeled for easy identification
- Buy With Confidence: If you have any questions about this electronic component assortment kit, please feel free to contact us and we will reply with in 24 hours. Sincerely wish you a happy shopping!
Gate-drive power is approximately:
Pgate ≈ QG × VGS × fPWM
Choose frequency for the particular motor, LED, heater, solenoid or converter, then verify the waveform and temperature. A product rating is not a general recommendation: TI’s DRV8317, for example, specifies PWM support up to 200 kHz for its integrated three-phase motor-driver architecture (TI DRV8317).
Why the transistor gets hot
For a switching MOSFET, begin with:
Pconduction ≈ IRMS2 × RDS(on)Pswitch ≈ 0.5 × VDS × ID × (tr + tf) × fPWM
These are first-order estimates. Include gate-drive, diode, reverse-recovery, output-capacitance, avalanche and ripple losses where relevant. Resistance rises with temperature, and package, copper area, airflow, duty cycle and stall current can dominate the result. TI notes that lower RDS(on) often trades against greater gate and output charge: TI MOSFET selection guidance. Check junction-temperature calculations rather than trusting a headline current rating.
Debugging symptoms
| Symptom | Likely causes and checks |
|---|---|
| No output | Wrong PWM pin, incorrect MOSFET pinout, no common ground, insufficient gate voltage, open supply or load. |
| Load always on | Floating gate, missing pulldown, damaged shorted MOSFET, source/drain error, or high-side gate never turning off. |
| MCU resets when PWM starts | Supply droop from startup/stall current, inadequate decoupling, ground bounce, load wired through the MCU regulator, or missing/reversed flyback protection. |
| MOSFET overheats | RDS(on) specified at a higher gate voltage, excessive current, too much gate charge for the frequency, poor PCB thermal path, or transients beyond the rating. |
| Motor whines | Frequency is in an audible range or current ripple is high. Try a suitable alternate frequency while checking switching losses and EMI. |
| LED brightness seems uneven | Human vision is nonlinear and LED current may not be regulated. Use a constant-current driver for high-power LEDs. |
| Solenoid releases slowly | A plain diode lets current decay slowly. Evaluate a TVS or zener clamp within the transistor’s voltage and energy limits. |
For abnormal behavior, measure gate-to-source voltage (not gate-to-ground for a moving high-side source) and inspect the drain waveform with an oscilloscope. Infineon explains the need for sufficient gate voltage and charge/discharge current in its gate-drive guidance.
Best Value
- Power Transistor / Voltage Regulator Assortment, 82 pcs and 24 types
- Includes Voltage Regulators, Power Transistors, Power MOSFETs, Thyristor / Triacs, Darlingtons:
- Voltage Regulators: 78L05, L7805, 79L05, L7905, 78L12, L7812, L7824, LM317, TL431, Thyristors: MAC97A6, BT134-600E, BTA06
- Power Transistors: TIP31C, TIP32C, TIP41C, TIP42C, D882, B772, BD139, BD140, Mosfets: IRF540, IRFZ44, Darlingtons: TIP122, TIP127
- The components come sorted accordingly in a labeled and handy box, includes 4 pcs Heatsinks
Low-side versus high-side switching
Low-side switching is simplest because an N-channel source stays at ground. It suits motors, solenoids, lamps and LED strips, but the load’s negative terminal is switched and may not remain a quiet reference for sensors or communications.
Use high-side switching when the load must stay ground-referenced or its positive rail must be disconnected. Options include a P-channel MOSFET, PNP transistor, integrated high-side switch, or an N-channel MOSFET with a floating high-side driver. The latter requires the gate to rise above the moving source; Analog Devices describes the added complexity in AN-006.
When one transistor is the wrong solution
- Use an H-bridge for forward/reverse motor control.
- Use a dedicated motor driver with current sensing and feedback for controlled torque or speed.
- Use a stepper driver for stepper motors and a three-phase BLDC driver for brushless motors.
- Use a constant-current LED driver rather than open-loop PWM for high-power LEDs.
- Use a gate-driver IC for large MOSFETs, fast PWM or complementary half-bridge switching.
- Use isolation and an engineered power stage for high voltage, mains or high-energy batteries.
For example, TI’s DRV8317 integrates three-phase FETs, 1.8/3.3/5 V logic support, current sensing and protection; it is a different class of solution from a single discrete low-side switch (product page).
Build and test checklist
- Record load voltage, running current, startup or stall current and inductive behavior.
- Select an external supply; do not route motor or solenoid power through the MCU regulator.
- Choose a MOSFET with guaranteed
RDS(on)at the GPIO voltage and adequate voltage, current and thermal margins. - Wire supply positive to the load, load to drain and source to supply negative.
- Join supply negative to MCU GND.
- Add the gate resistor and a pulldown to source.
- Add the correctly oriented flyback diode and nearby supply capacitors.
- Start at low duty cycle, check that the load behaves correctly and monitor transistor temperature.
- Increase duty cycle or frequency only after checking current, drain transients and thermal performance.
- Move high-current or fast-switching circuits from a solderless breadboard to a short, wide-trace PCB.
Solderless breadboards are unsuitable for high-current, high-frequency or high-energy switching loops. Enclose and fuse circuits with hazardous voltage or fault energy, and use a professionally designed power stage when the consequences of failure are serious.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

