Home · Academy · Robotics & Coding · Sensors and Actuators · DC Motors and Motor Drivers

DC Motors and Motor Drivers

Learn to control a DC motor's speed and direction safely with a driver and separate power.

LESSON COMPASS

What will you use this page for?

Core idea

A DC motor turns electrical energy into continuous spinning; to control its speed and direction and to run it safely, we use a motor driver together with a separate power source.

Evidence to produce

Complete the page task with your own input, test conditions and reasoning.

Control trap

Connecting the motor straight to the board Wiring the motor directly to a micro:bit or Arduino pin is the most common and most dangerous mistake. Always use a motor driver. Not separating the power source If the motor and the board share the same weak source, the board may reset or the motor may not spin. Give the…

Next connection

What Is a Stepper Motor?

Module sources: Python Tutorial · Arduino Learn

LevelBeginner
Age10–16
Duration30–45 min
PrerequisiteThe Servo Motor
ContentStandard lesson · 1,504 words
Last updated

One-sentence summary

A DC motor turns electrical energy into continuous spinning; to control its speed and direction and to run it safely, we use a motor driver together with a separate power source.

Why does it matter?

We learned about the servo motor in the previous lesson. A servo turns to a specific angle and stops there, which is great for setting the position of an arm or a steering part. But if you want to spin a robot's wheel, you need a motor that keeps turning. That is exactly what a DC motor does.

Toy cars, desk fans, electric toothbrushes and many robot wheels run on DC motors. So almost everyone who starts building robots meets a DC motor at some point.

There is an important safety and engineering point here, though. A DC motor draws far more current than a small LED. If you connect a motor directly to a pin on your micro:bit or Arduino, you can damage the board. In this lesson we will learn why we power the motor separately and what a motor driver is for.

What is a DC motor and how does it work?

What does it do?

A DC motor runs on direct current (DC) and gives the shaft a continuous spinning motion. It has two connection terminals. When you connect a battery, the shaft spins; if you swap the terminals, it spins the other way.

A simple idea of how it spins

Inside there is a magnet and a coil that becomes magnetic when electricity flows through it. As current passes, the coil pushes and pulls against the magnet and turns the shaft. In other words, electrical energy becomes movement. We can sum up the idea like this:

How it differs from a servo

Two everyday examples

Why don't we power the motor straight from the board?

The current problem

An LED draws very little current, so we can connect it directly to a pin. A DC motor, on the other hand, needs much more current while running, especially at the very start of a spin. The pins on a micro:bit or Arduino cannot supply that much current.

Simple rule: A board's pin is not built to spin a motor. The pin only gives an "order"; the power must come from somewhere else.

If you connect a motor straight to a pin, two bad things can happen: the board cannot supply enough current so the motor barely turns, or the board is overloaded and the pin or board is damaged.

The solution: a motor driver

A motor driver is a helper that takes the small signal from the board and powers the motor from a separate power source. Common classroom examples are boards like the L298N and L9110.

A motor driver does two jobs at once:

  1. It uses the board's small signal to switch the motor on/off and choose its direction.
  2. It draws the current the motor needs from a separate power source (such as a battery pack), which protects your board.

Think of it like a tap: your finger nudges a small lever (the signal), but the water that flows comes from the pipe (the separate power). Your finger uses little force, while the water comes from the pipe's pressure.

How are speed and direction controlled?

Pseudocode and example

The pseudocode below shows how we control a motor through a driver. The real pin numbers depend on the board you use.

Start
Set motor power very low (for example 30%)
Choose the forward direction
Spin forward for 2 seconds
Stop the motor
Choose the backward direction
Spin backward for 2 seconds
Stop the motor
End

A micro:bit-style snippet (the logic stays the same):

# We control the motor with a separate power source and a driver
drv = MotorDriver(dir_pin=1, speed_pin=2)

drv.direction("forward")
drv.speed(30)        # start at low speed (30%)
sleep(2000)          # spin for 2 seconds

drv.stop()
drv.direction("backward")
drv.speed(30)
sleep(2000)
drv.stop()           # stop the motor when we are done

Notice that the speed starts low (30%). We always test the motor at low speed and then increase it.

Mini practice

Design a desk-fan behaviour: the motor spins slow, then medium, then fast, then changes direction and stops. Write the pseudocode first, then try it with an adult using a driver and a battery pack.

Start
Direction: forward
Speed 30%, wait 2 seconds
Speed 60%, wait 2 seconds
Speed 90%, wait 2 seconds
Stop the motor
Direction: backward
Speed 40%, wait 2 seconds
Stop the motor
End

Check yourself:

Common mistakes

Connecting the motor straight to the board

Wiring the motor directly to a micro:bit or Arduino pin is the most common and most dangerous mistake. Always use a motor driver.

Not separating the power source

If the motor and the board share the same weak source, the board may reset or the motor may not spin. Give the motor its own battery pack.

Starting at high speed

Running the motor at full speed at once can pull cables or send the robot off the table. Start slow and increase gradually.

Changing direction suddenly

Sending a "backward" command while the motor is spinning forward at full speed strains the driver and the motor. Stop first, then set the reverse direction.

Safety note

DC motors are spinning, moving parts. To work safely:

Lesson summary

Review questions

  1. What is the most basic difference between a DC motor and a servo motor?
  2. How do we change the direction in which a motor spins?
  3. Why don't we connect a DC motor straight to a micro:bit or Arduino pin?
  4. What are the two main jobs of a motor driver?
  5. Where should the motor's power come from, and at what speed should we start it?

Answers

  1. A DC motor spins continuously (speed/direction control); a servo moves to a set angle and stops (position control).
  2. We reverse the terminals on the motor; the driver's "forward/backward" command does this.
  3. Because a DC motor draws too much current; the board's pin cannot supply it and the board could be damaged.
  4. Switching the motor on/off and choosing its direction from the board's signal, and powering the motor from a separate source to supply the needed current.
  5. From a separate, low-voltage source (a battery pack/USB); we should start the motor at low speed and increase it slowly.

Source and verification note

For “DC Motors and Motor Drivers”, verification focuses on whether the relationship between What is a DC motor and how does it work? and A simple idea of how it spins remains consistent across examples. Sensor readings can change with the model, supply voltage and environment. Thresholds in the lessons are therefore examples; a real project should use a measurement table and calibration.

Next lesson

What Is a Stepper Motor?

Start QuizBack to Sensors and Actuators
QUESTION POOL

Reinforce this lesson with 10 questions

This lesson has a pool of 20 questions. Each attempt selects 10 and reshuffles the choices.