Arduino Circuits

DC Motor PWM Speed Control

Control the speed of a DC motor safely with a transistor driven by an Arduino PWM output.

22 November 20265 min read
DC Motor PWM Speed Control circuit with an Arduino, transistor, potentiometer and motor on a breadboard
Breadboard layout, components and jumper connections of the DC Motor PWM Speed Control circuit.

Interactive circuit guide

Run the simulation, follow the build steps one by one and try it in our real app.

Real screenshot of our circuit simulator Stopped
Open in our app →

Step-by-step build

What is it for?

Arduino pins cannot drive a motor directly; the current a motor needs exceeds the pin capacity. In this circuit the Arduino PWM output drives an NPN transistor through a 1 kiloohm base resistor. The transistor works as a low-side switch: one end of the motor goes to the supply and the other to the transistor collector. A flyback diode placed across the motor absorbs the voltage spike produced by the coil when the transistor switches off, protecting the circuit. The middle leg of the potentiometer goes to an Arduino analogue input and provides the speed reference. The motor is powered by a separate 9V source whose negative terminal shares a common ground with the Arduino GND. On the breadboard, build the power and ground rails first, then connect the motor and transistor branch.

Parts list

The following components are used to build this project:

  • Arduino Uno × 1 — Generates the PWM signal and reads the potentiometer.
  • NPN transistor × 1 — Switches the motor current.
  • DC motor × 1 — Converts electrical energy into rotation.
  • 9V battery × 1 — Separate power source for the motor.
  • 10 kΩ potentiometer × 1 — Provides the speed reference.
  • 1N4007 diode × 1 — Suppresses the voltage spike from the coil.
  • 1kΩ resistor × 1 — Keeps the base current in a safe range.
  • Ground connection × 1 — Common reference for all circuits.

Build it step by step

  1. Place the Arduino and motor on the breadboard and connect GND to the ground rail.Tip: establish the common ground first, then run the power wires.
  2. Connect the 9V battery positive to the motor positive terminal and its negative to common ground.Tip: never take motor power from the Arduino.
  3. Connect the flyback diode across the two motor terminals, with the cathode on the positive side.Tip: a reversed diode creates a short circuit.
  4. Connect the motor negative terminal to the transistor collector and the emitter to ground.Tip: do not mix up collector and emitter.
  5. Connect the Arduino PWM pin to the transistor base through the 1kΩ resistor.Tip: without a base resistor the transistor can be damaged.
  6. Connect the potentiometer to 5V and ground, feed the wiper to the analogue input and upload the code.Tip: changing the wiper reading should change the motor speed.

How it works

PWM (pulse width modulation) controls power not by changing the voltage continuously, but by changing how long the pulse stays on. As the duty cycle increases, more average voltage reaches the motor and it spins faster. The Arduino pin supplies only a control signal; the motor current comes from the separate battery through the transistor. The transistor base current is limited by a 1 kiloohm resistor. When the coil current is interrupted, the collapsing magnetic field generates a high reverse voltage; the parallel flyback diode circulates that energy inside the coil and protects the transistor. Commoning the Arduino GND with the battery negative is required for the PWM signal to be read correctly.

Layout tip: the Arduino is on the left, the motor at the top right and the transistor below the motor. The 9V battery positive goes to the motor positive and the diode cathode, its negative to common ground. The motor negative goes to the collector and the emitter to common ground. The potentiometer goes between 5V and ground with its wiper at the analogue input.

What you learn

  • Explains the relationship between PWM and average voltage.
  • Uses the transistor as a load switch.
  • Knows the protective function of the flyback diode.
  • Applies the principles of a separate supply and a common ground.

Tips

  • Place the diode very close to the motor.
  • If the motor does not turn, check the base resistor and the emitter ground.
  • At low speeds the motor may judder; this is normal.
  • A very low PWM frequency makes the motor whine.

Try it yourself

  • Set the speed: Turn the potentiometer to change the motor speed. The motor speeds up as the wiper value increases.
  • Check the protection: Observe that the diode and base resistor are fitted. The flyback diode and the 1kΩ resistor are in the circuit.

Getting the parts

If you want to build this project in real life, you can get the parts from hobidevre.com.

Frequently asked questions

What is this circuit for?

It controls the speed of a DC motor safely with a transistor driven by an Arduino PWM output.

How does the circuit work?

PWM varies the duty cycle to change the average voltage at the motor. The Arduino pin only provides a control signal; motor current comes from a separate 9V battery through the transistor. A base resistor limits base current and a flyback diode suppresses the coil voltage spike.

What is the expected result?

The motor speed changes gradually with the potentiometer, and the transistor runs safely with the diode and resistor fitted.

You may also like

Try the circuit in the simulator

Open the schematic in the browser, inspect the connections and follow the steps.