Skip to content
BoKSA

Motors and Actuators

Motors and Actuators

Introduction

Microcontrollers think in volts and code; robots move in millimeters and newtons. Actuators turn your firmware into motion: wheels spin, arms lift, grippers close. The hard part is not the digitalWrite — it is current, direction, timing, and power supplies that do not brown out your MCU.

This article covers DC motors, servos, stepper motors, H-bridges, and relays — the actuators you meet most often in embedded and robotics projects. Theory links: Pulse width modulation, Basics of electronics.


GPIO cannot drive motors directly

Problem Why
Current GPIO ~20 mA; small motor wants hundreds of mA
Inductance Coils spike voltage when switched off — kills transistors
Direction Reversing polarity needs an H-bridge, not one GPIO

Use a driver IC (L298N, DRV8833, TB6612) or relay module between MCU and load. Separate supply for motors; common GND with MCU.

In plain terms

A GPIO pin is a finger flicking a light switch. A motor is a refrigerator compressor — you need a proper relay box, not your finger.


DC motors

Brushed DC motors spin faster with more voltage; direction swaps when you reverse polarity.

Control How
Speed PWM on enable pin of driver
Direction H-bridge IN1/IN2 pattern
Stop Brake (both LOW) or coast — driver dependent

Flyback protection — driver chips include diodes; raw transistor switches need a flyback diode across the coil.


H-bridge — forward and reverse

An H-bridge is four switches (usually transistors) arranged so current can flow through the motor left-to-right or right-to-left.

1
2
3
4
5
6
7
        +V
         |
    [S1]---[S2]
         |M|
    [S3]---[S4]
         |
        GND
IN1 IN2 Motor
HIGH LOW Forward
LOW HIGH Reverse
LOW LOW Coast / brake (chip-specific)

Never turn on both high-side and low-side on the same half (shoot-through) — use a driver IC that prevents it.

Common modules: L298N (classic, inefficient), DRV8833 (3.3 V logic, efficient), TB6612.


Servo motors

A servo moves to an angle, not just "spin." Inside: motor, gearbox, potentiometer feedback, and control IC.

Control signal: PWM on signal wire, typically 50 Hz (20 ms period):

Pulse width Position (typical hobby servo)
~1.0 ms ~0° (one end)
~1.5 ms ~90° (center)
~2.0 ms ~180° (other end)

Wiring (common):

Wire color Role
Brown / black GND
Red Power (often 5 V, not from MCU 3.3 V pin)
Orange / yellow PWM signal

When to choose servo: known angle, limited range, moderate torque — pan/tilt, gripper jaw, steering linkage.

MCU tip: use a hardware timer PWM channel; do not bit-bang servos while Wi-Fi runs.


Stepper motors

Steppers move in discrete steps — no encoder needed for open-loop positioning if load is light.

Type Coils Wiring
Unipolar Center-tapped Simpler drive, 5 wires common
Bipolar No center tap More torque; needs H-bridge per coil pair

NEMA numbers describe faceplate size (e.g. NEMA 17 ≈ 42 mm square) — not torque alone. Read datasheet for holding torque (often in N·cm or oz·in).

Microstepping — driver chops current between steps for smoother motion and finer resolution.

When to choose stepper: 3D printer axis, CNC, precise rotation without servo range limit — needs a stepper driver (A4988, DRV8825, TMC2209).


Relays

A relay is an electrically operated switch — MCU drives a small coil, contacts switch mains or high current loads.

Use Example
Isolation MCU 3.3 V logic, 230 V lamp (with proper safety training)
High current Heater, pump, large lamp

Flyback diode across relay coil if module does not include one. Prefer relay modules with opto-isolation and LED indicator for labs.


Power and noise

  • Motor supply ≠ MCU supply — tie grounds at one point.
  • 100 nF on driver IC; bulk cap (100–470 µF) on motor rail.
  • Motor noise on ADC readings — separate analog ground path or filter.

Videos — other ways to learn

H-bridge operation

H-Bridge Circuit Operations Explained

L298N and DC motor

Controlling DC Motors with the L298N H Bridge and Arduino

Motor speed controller

H Bridge Motor Speed Controller Tutorial

Servos

Electronic Basics #25: Servos and how to use them

Stepper motors

Stepper Motors with Arduino - Controlling Bipolar & Unipolar stepper motors

Relays

How Relays Work - Basic working principle


Relevant topics


Starting points

  1. Blink a LED with PWM — then swap LED for motor driver enable pin.
  2. Wire L298N with separate 12 V supply; measure MCU 3.3 V rail while motor starts.
  3. Sweep one servo 0°–180° in firmware; scope the pulse width on signal pin.
  4. Step a NEMA 17 with A4988 at low current before mounting to mechanics.

Focus points

  • Stall current — blocked motor draws max current; size supply and driver.
  • Safe state on boot — motors off until firmware initializes driver.
  • EMI — long motor wires act as antennas; twist pairs, keep away from I²C.
  • Mechanical limit — software end-stops even for servos and steppers.

Key points

  • Motors need drivers, protection, and usually a separate power supply.
  • H-bridge = direction; PWM = speed; servo PWM = angle; stepper = counted steps.
  • Relays isolate heavy or mains loads — respect lab safety rules.
  • Document motor pins and supplies in pin map, wiring diagram, and BOM.