You dont have javascript enabled! Please enable it!

Practical case: DC motor control with a transistor

DC motor control with a transistor prototype (Maker Style)

Level: Basic – Learn to use an NPN transistor as a switch to drive a DC motor, including the use of a flyback diode.

Objective and use case

In this practical case, you will build a low-side switch circuit using an NPN transistor to safely control a high-current DC motor from a low-power control signal.

This topology is highly useful in the real world for several reasons:
* Interfacing low-voltage microcontrollers (like an Arduino or Raspberry Pi) with higher power loads that require external power supplies.
* Automating small cooling fans in temperature-controlled systems.
* Building basic drive systems for small hobbyist robotics.
* Protecting delicate control logic from the damaging voltage spikes generated by inductive loads.

Expected outcome:
* Applying a 5 V control signal to the base circuit will saturate the transistor.
* The DC motor will spin as the transistor bridges its connection to ground.
* The flyback diode will safely dissipate the motor’s inductive kickback when the control signal is turned off.
* Measurable base voltage (VBE) around 0.7 V, near-zero collector-emitter voltage (VCE) indicating saturation, and clearly observable base current (IB) and collector current (IC).

Target audience and level: Beginners in electronics and hobbyists looking to control mechanical loads safely.

Materials

  • V1: 9 V DC supply, function: main power source for the DC motor
  • V2: 5 V DC supply, function: simulated control signal source
  • SW1: SPST switch, function: manual control of the base signal
  • Q1: 2N2222 NPN transistor, function: low-side switch to drive the motor
  • M1: 9 V DC motor, function: inductive mechanical load
  • D1: 1N4007 diode, function: flyback diode to suppress inductive spikes
  • R1: 1 kΩ resistor, function: base current limiting resistor
  • R2: 10 kΩ resistor, function: pull-down resistor for the control signal

Wiring guide

  • V1: connects between nodes 9 V_PWR and 0
  • V2: connects between nodes 5 V_CTRL and 0
  • SW1: connects between nodes 5 V_CTRL and CTRL_IN
  • R2: connects between nodes CTRL_IN and 0
  • R1: connects between nodes CTRL_IN and BASE
  • Q1: Collector connects to node COLLECTOR, Base connects to node BASE, Emitter connects to node 0
  • M1: connects between nodes 9 V_PWR and COLLECTOR
  • D1: Anode connects to node COLLECTOR, Cathode connects to node 9 V_PWR

Conceptual block diagram

Conceptual block diagram — Transistor Motor Control
Quick read: inputs → main block → output (actuator or measurement). This summarizes the ASCII schematic below.

Schematic

[ 5 V_CTRL ] --> [ SW1 ] --(CTRL_IN)--+--> [ R1: 1 kΩ ] --(BASE)--> [ Q1:Base ]
                                           |                                |
                                       [ R2: 10 kΩ ]                         |
                                           |                                |
                                          GND                               |
                                                                            |
      [ 9 V_PWR ] --+--> [ M1: 9 V Motor ] -----------------+--(COLLECTOR)--> [ Q1:Collector ] --( )-- [ Q1:Emitter ] --> GND
                   |                                      |
                   +--> [ D1: 1N4007 (Cath->Anode) ] -----+
Electrical Schematic

Electrical diagram

Electrical diagram for case: DC motor control with a transistor
Generated from the validated SPICE netlist for this case.

🔒 This electrical diagram is premium. With the 7-day pass or the monthly membership you can unlock the complete didactic material and the print-ready PDF pack.🔓 See premium access plans

Measurements and tests

  1. Verify Control Signal: Close SW1. Measure the voltage at node CTRL_IN with respect to node 0. It should read 5 V. When open, it should read 0 V due to the pull-down resistor R2.
  2. Measure Base-Emitter Voltage (VBE): With SW1 closed, place your multimeter probes across node BASE and node 0. You should measure approximately 0.7 V, confirming the transistor’s base-emitter junction is forward-biased.
  3. Measure Collector-Emitter Voltage (VCE): With the motor running (SW1 closed), measure the voltage between node COLLECTOR and node 0. A reading of around 0.2 V indicates the transistor is correctly operating in the saturation region. When SW1 is open, this voltage should rise to 9 V.
  4. Measure Base Current (IB): Set your multimeter to measure current (mA range) and place it in series between R1 and node BASE. You should measure a small current (around 4.3 mA).
  5. Measure Collector Current (IC): Place your ammeter in series between M1 and node COLLECTOR. You will measure the actual current drawn by the motor (which could range from tens to hundreds of mA depending on the specific motor).

SPICE netlist and simulation

Reference SPICE Netlist (ngspice) — excerptFull SPICE netlist (ngspice)

* DC Motor Control with a Transistor
.width out=256

* Power Supplies
V1 9V_PWR 0 DC 9
V2 5V_CTRL 0 DC 5

* Switch SW1 modeled as a voltage-controlled switch to simulate user interaction
S1 5V_CTRL CTRL_IN SW_CTRL 0 mySW
.model mySW SW(Vt=2.5 Vh=0.5 Ron=0.1 Roff=100MEG)

* Control signal to simulate the user pressing the switch
V_SW_CTRL SW_CTRL 0 PULSE(0 5 10m 1u 1u 245m 1s)

* Resistors
R2 CTRL_IN 0 10k
R1 CTRL_IN BASE 1k

* Transistor Q1 (Low-side switch)
Q1 COLLECTOR BASE 0 2N2222MOD
* ... (truncated in public view) ...

Copy this content into a .cir file and run with ngspice.

🔒 Part of this section is premium. With the 7-day pass or the monthly membership you can access the full content (materials, wiring, detailed build, validation, troubleshooting, variants and checklist) and download the complete print-ready PDF pack.

* DC Motor Control with a Transistor
.width out=256

* Power Supplies
V1 9V_PWR 0 DC 9
V2 5V_CTRL 0 DC 5

* Switch SW1 modeled as a voltage-controlled switch to simulate user interaction
S1 5V_CTRL CTRL_IN SW_CTRL 0 mySW
.model mySW SW(Vt=2.5 Vh=0.5 Ron=0.1 Roff=100MEG)

* Control signal to simulate the user pressing the switch
V_SW_CTRL SW_CTRL 0 PULSE(0 5 10m 1u 1u 245m 1s)

* Resistors
R2 CTRL_IN 0 10k
R1 CTRL_IN BASE 1k

* Transistor Q1 (Low-side switch)
Q1 COLLECTOR BASE 0 2N2222MOD

* Motor M1 modeled as a series inductor and resistor representing the inductive mechanical load
LM1 9V_PWR M1_INT 1mH
RM1 M1_INT COLLECTOR 20

* Flyback diode D1
D1 COLLECTOR 9V_PWR 1N4007MOD

* Component Models
.model 2N2222MOD NPN(IS=1E-14 VAF=100 BF=200 IKF=0.3 XTB=1.5 BR=3 CJC=8E-12 CJE=25E-12 TR=100E-9 TF=400E-12 ITF=1 VTF=2 XTF=3 RB=10 RC=0.3 RE=0.2)
.model 1N4007MOD D(IS=7.02767n RS=0.0341512 N=1.80803 EG=1.11 XTI=3.0 BV=1000 IBV=5e-08 CJO=1e-11 VJ=0.7 M=0.5 FC=0.5 TT=1e-07)

* Simulation Commands
.op
.tran 0.1m 250m
.print tran V(CTRL_IN) V(COLLECTOR) V(BASE) I(LM1)
.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Analysis: The simulation shows that when the control signal (v(ctrl_in)) goes high to ~5V at t=10ms, the transistor turns on, pulling the collector voltage down from 9V to ~1.64V. The base voltage rises to ~0.94V, and the motor current (lm1#branch) ramps up to ~368mA, indicating successful motor activation.
Show raw data table (2541 rows)
Index   time            v(ctrl_in)      v(collector)    v(base)         lm1#branch
0	0.000000e+00	5.000400e-04	9.000000e+00	5.000490e-04	1.799750e-11
1	1.000000e-06	5.000400e-04	9.000000e+00	5.000490e-04	1.800624e-11
2	2.000000e-06	5.000400e-04	9.000000e+00	5.000490e-04	1.800815e-11
3	4.000000e-06	5.000400e-04	9.000000e+00	5.000490e-04	1.800528e-11
4	8.000000e-06	5.000400e-04	9.000000e+00	5.000490e-04	1.799050e-11
5	1.600000e-05	5.000400e-04	9.000000e+00	5.000490e-04	1.798412e-11
6	3.200000e-05	5.000400e-04	9.000000e+00	5.000490e-04	1.797999e-11
7	6.400000e-05	5.000400e-04	9.000000e+00	5.000490e-04	1.798801e-11
8	1.280000e-04	5.000400e-04	9.000000e+00	5.000490e-04	1.797977e-11
9	2.280000e-04	5.000400e-04	9.000000e+00	5.000490e-04	1.799637e-11
10	3.280000e-04	5.000400e-04	9.000000e+00	5.000490e-04	1.799685e-11
11	4.280000e-04	5.000400e-04	9.000000e+00	5.000490e-04	1.799640e-11
12	5.280000e-04	5.000400e-04	9.000000e+00	5.000490e-04	1.799689e-11
13	6.280000e-04	5.000400e-04	9.000000e+00	5.000490e-04	1.799636e-11
14	7.280000e-04	5.000400e-04	9.000000e+00	5.000490e-04	1.799685e-11
15	8.280000e-04	5.000400e-04	9.000000e+00	5.000490e-04	1.799639e-11
16	9.280000e-04	5.000400e-04	9.000000e+00	5.000490e-04	1.799690e-11
17	1.028000e-03	5.000400e-04	9.000000e+00	5.000490e-04	1.799645e-11
18	1.128000e-03	5.000400e-04	9.000000e+00	5.000490e-04	1.799690e-11
19	1.228000e-03	5.000400e-04	9.000000e+00	5.000490e-04	1.799640e-11
20	1.328000e-03	5.000400e-04	9.000000e+00	5.000490e-04	1.799689e-11
21	1.428000e-03	5.000400e-04	9.000000e+00	5.000490e-04	1.799641e-11
22	1.528000e-03	5.000400e-04	9.000000e+00	5.000490e-04	1.799690e-11
23	1.628000e-03	5.000400e-04	9.000000e+00	5.000490e-04	1.799640e-11
... (2517 more rows) ...

Common mistakes and how to avoid them

  • Omitting the flyback diode (D1): A DC motor is an inductive load. When the transistor turns off, the collapsing magnetic field creates a massive voltage spike. Without the diode, this spike will instantly destroy the transistor. Always place a diode in parallel with the motor, reverse-biased relative to the normal current flow.
  • Forgetting the base resistor (R1): Connecting a 5 V control signal directly to the transistor’s base will draw excessive current, immediately destroying the control source (e.g., your microcontroller) or the transistor. Always use a current-limiting resistor.
  • Swapping the Collector and Emitter pins: Inserting the NPN transistor backward will result in very poor current gain (hFE). The motor may barely turn, and the transistor will heat up significantly because it cannot fully saturate. Double-check the datasheet for your specific transistor’s pinout.

Troubleshooting

  • Symptom: The motor does not spin when the switch is closed.
    • Cause: The transistor is not turning on, or the motor lacks power.
    • Fix: Measure the voltage at node BASE. If it is 0 V, check your switch SW1 and resistor R1. Measure node 9 V_PWR to ensure the main power supply is active.
  • Symptom: The transistor becomes extremely hot very quickly.
    • Cause: The transistor is operating in the active/linear region instead of fully saturating, usually because the base current (IB) is too low for the required collector current (IC).
    • Fix: Calculate the required base current (IC / hFE). If the current is too low, reduce the value of R1 (e.g., to 470 Ω or 330 Ω) to allow more base current, ensuring saturation.
  • Symptom: The microcontroller resets or behaves erratically when the motor turns on/off.
    • Cause: Electrical noise from the motor brushes or voltage drops on the power line.
    • Fix: Ensure the motor power supply (V1) is completely separate from the control logic supply (V2), sharing only the ground (0) connection. Add a 100 nF ceramic capacitor across the motor terminals to suppress brush noise.

Possible improvements and extensions

  • PWM Speed Control: Replace the manual switch (SW1) with a Pulse Width Modulation (PWM) signal from a microcontroller. By rapidly turning the transistor on and off, you can smoothly control the rotational speed of the motor rather than just having it on or off.
  • Optoisolation for superior safety: Introduce an optocoupler between the control signal and the transistor base. This physically separates the low-voltage control circuit from the higher-voltage motor circuit using light, providing total electrical isolation and preventing catastrophic failures from reaching your logic board.

More Practical Cases on Prometeo.blog

Find this product and/or books on this topic on Amazon

Go to Amazon

As an Amazon Associate, I earn from qualifying purchases. If you buy through this link, you help keep this project running.

Quick Quiz

Question 1: What is the primary objective of the circuit described in the context?




Question 2: What type of switch circuit is built using the NPN transistor in this practical case?




Question 3: Why is this topology useful for microcontrollers like Arduino or Raspberry Pi?




Question 4: What is the purpose of the flyback diode in this circuit?




Question 5: What happens when a 5 V control signal is applied to the base circuit?




Question 6: How does the DC motor spin in this circuit configuration?




Question 7: What is the expected measurable base-emitter voltage (V_BE) when the transistor is saturated?




Question 8: What collector-emitter voltage (V_CE) indicates that the transistor is in saturation?




Question 9: Which of the following is a real-world application mentioned for this circuit?




Question 10: What type of load is a DC motor considered in the context of voltage spikes?




Carlos Núñez Zorrilla
Carlos Núñez Zorrilla
Electronics & Computer Engineer

Telecommunications Electronics Engineer and Computer Engineer (official degrees in Spain).

Follow me:
Scroll to Top