Projects / MOSFET motor speed control lab

MOSFET motor speed control lab

Beginner2.5 hGuided buildReviewed

Build it step by step

0 of 9 done
  1. UNOIRFZ44

    Place the MOSFET

    Put it in the breadboard with its flat face towards you, legs gate, drain, source from the left.

  2. UNOIRFZ44+

    Wire the ground

    MOSFET source to the battery minus and to the Uno GND.

  3. UNO

    Wire the gate

    Uno D9 through 220 ohms to the gate, and 10 k from the gate to ground.

  4. UNOIRFZ44

    Wire the motor

    Battery plus to one motor terminal, the other terminal to the MOSFET drain.

  5. UNO+

    Add the flyback diode

    Stripe to the battery plus, the other end to the drain.

  6. UNO

    Wire the knob

    Pot outer legs to 5V and GND, middle to A0.

  7. UNO

    Upload the sketch

    The monitor prints a message and the motor is stopped.

  8. UNO

    Turn the knob slowly

    The motor starts, speeds up and the monitor shows the duty.

  9. UNO

    Fill in a table

    Write down the duty and the rpm from your phone at 5 points.

In short

How do you build an MOSFET motor speed control lab?

A knob sets the speed of a small DC motor using PWM and a MOSFET, with a flyback diode to protect the circuit. The serial monitor shows the duty cycle so you can plot duty against speed with a phone tachometer app. You need Arduino Uno R3, IRFZ44N N-channel MOSFET, DC motor 130 size (toy motor), Rectifier Diode 1N4007, Resistor 220 Ω, Resistor 10 kΩ, Potentiometer 10 kΩ, Battery holder 4 × AA with switch, AA alkaline battery × 4, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm). It takes 9 steps and about 150 minutes.

Level
Beginner
Time
About 150 min
Parts
11
See the electronics first. This build uses MOSFET switch. Try a MOSFET switch in the circuit builder and watch the voltages and currents before you wire it.

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
4 AA battery holder +Motor terminal 1Motor supply, about 6 V
Motor terminal 2MOSFET drain (middle leg)The MOSFET switches the ground side
1N4007Stripe to the battery +, other end to the drainAcross the motor, absorbs the spike when it switches off
MOSFET sourceBattery - and Uno GNDAll grounds joined together
MOSFET gate220 ohm to Uno D9PWM pin
10 k from gate to sourceGate to GNDHolds the motor off while the Uno restarts
Pot outer legsUno 5V and GNDSpeed knob
Pot middle legUno A0Chooses the duty cycle

Code

A motor needs far more current than an Arduino pin can give, so the pin only controls a switch, the MOSFET, and the battery supplies the motor. The MOSFET sits between the motor and ground. When the gate is at 5 V, current flows through the motor, and when the gate is at 0 V it stops. To change the speed, analogWrite() switches it on and off about 490 times a second, and the share of each cycle that it is on, the duty cycle, sets the average power. The motor's own inertia smooths the pulses, so 50 percent duty makes it run at about half power. Three small parts matter a great deal. The 10 k resistor from gate to ground keeps the motor off while the Uno is starting or being programmed. The 220 ohm resistor in series with the gate limits the surge into the pin. The 1N4007 diode is across the motor, backwards, and it gives the energy in the motor's coil a path when the MOSFET switches off. Without it the spike could damage the MOSFET and the Uno. The IRFZ44N is not a logic level MOSFET, so with only 5 V on the gate it is not fully on, but a small 130 motor at about half an amp is within its limit, and the MOSFET should be only slightly warm. For bigger motors choose a logic-level part such as the IRLZ44N. The sketch ignores the first few counts of the knob because a toy motor only hums below about 5 percent. Use a phone tachometer app or count marks with a slow motion video to plot duty against speed. Always join the battery ground to the Uno ground.

Runs on a virtual Arduino Uno in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

const uint8_t MOTOR = 9;           // PWM pin to the MOSFET gate
const uint8_t POT = A0;
const uint8_t DEAD_BAND = 12;      // below this duty a toy motor only hums, so treat it as stopped

int lastShown = -1;
unsigned long lastPrint = 0;

void setup() {
  pinMode(MOTOR, OUTPUT);
  analogWrite(MOTOR, 0);
  Serial.begin(9600);
  Serial.println(F("Motor lab: turn the knob, read the duty"));
}

void loop() {
  int raw = analogRead(POT);                    // 0 to 1023
  int duty = map(raw, 0, 1023, 0, 255);
  if (duty < DEAD_BAND) duty = 0;
  analogWrite(MOTOR, duty);

  int percent = duty * 100 / 255;
  if (percent != lastShown && millis() - lastPrint > 500) {   // print only when it changes
    lastShown = percent;
    lastPrint = millis();
    Serial.print(F("Duty "));
    Serial.print(duty);
    Serial.print(F(" of 255 = "));
    Serial.print(percent);
    Serial.println(F("%"));
  }
  delay(10);
}

What the serial monitor should show

Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual Arduino Uno with its sensors at their default values. Your numbers will follow your real readings, but the format should match.

Motor lab: turn the knob, read the duty
Duty 127 of 255 = 49%

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Knob at zeroMotor stopped, no humming
Knob a little upMotor starts turning after a small dead zone
Knob at halfMonitor shows about 50 percent and the motor runs at medium speed
Knob at full100 percent, full speed
Touch the MOSFET after a minute at fullOnly slightly warm
Unplug and plug in the Uno with the motor battery connectedThe motor stays off during start-up

If it does not work

Motor does not turn

Check the battery, the diode direction and that the drain goes to the motor.

Motor runs all the time

The gate pulldown is missing, so add the 10 k from gate to ground.

MOSFET is hot

It is not fully on with 5 V, so use a logic-level MOSFET like the IRLZ44N or a smaller motor.

Uno resets when the motor starts

Power the motor from the battery, not the Uno, and add a 100 uF capacitor across the motor.

Motor only hums at low duty

That is normal, the dead band hides it.

Readings jump

Add a 100 nF capacitor from A0 to GND.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the MOSFET motor speed control lab?

Arduino Uno R3, IRFZ44N N-channel MOSFET, DC motor 130 size (toy motor), Rectifier Diode 1N4007, Resistor 220 Ω, Resistor 10 kΩ, Potentiometer 10 kΩ, Battery holder 4 × AA with switch, AA alkaline battery × 4, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm).

How long does the MOSFET motor speed control lab take to build?

About 150 minutes for a beginner maker, in 9 steps.

How do I know the MOSFET motor speed control lab works?

Knob at zero: Motor stopped, no humming. Knob a little up: Motor starts turning after a small dead zone. Knob at half: Monitor shows about 50 percent and the motor runs at medium speed.

Motor does not turn: what should I check?

Check the battery, the diode direction and that the drain goes to the motor.

Motor runs all the time: what should I check?

The gate pulldown is missing, so add the 10 k from gate to ground.

MOSFET is hot: what should I check?

It is not fully on with 5 V, so use a logic-level MOSFET like the IRLZ44N or a smaller motor.

Uno resets when the motor starts: what should I check?

Power the motor from the battery, not the Uno, and add a 100 uF capacitor across the motor.