Embedded track
Motor control

A motor control course: DC, servo, stepper and encoder

Speed and direction on a driver, the H bridge inside it, angles on a servo, STEP and DIR on an A4988, and an encoder that measures what really happened.

FreeIn your browser2 courses, 15 lessons, about 10 hours
Start freeA DC motor on a driver: speed and directionSee the course
Overview

How you will learn it

A motor is the point where code meets the physical world, and each kind needs a different approach. DC motors need a driver and PWM, servos want an angle, steppers move in counted steps, and an encoder tells you whether any of it worked.

Motors and motion covers all four on a simulated Uno and ends with a robot car that avoids walls and follows lines. Every wire and every pulse is visible, so you can see what the driver is doing.

Outcomes

What you will learn

  • Drive a DC motor through a driver with PWM speed and direction.
  • Explain the H bridge and why the motor needs one.
  • Position a servo and step a stepper with an A4988.
  • Measure real motion with an encoder and close the loop.
Your route

The courses and lessons to take

Every lesson opens in the editor right away, signed in or not, and the simulator checks each step.

  1. Step 1 · 7 lessons · 4 h

    Motors and motion

    The whole course.

    1. A DC motor on a driver: speed and directionTwo gear motors on an L298N: why a pin cannot run a motor, two inputs for direction, PWM on the enable for speed, and the volts a bipolar driver keeps for itself.
    2. Inside the driver: the H bridgeFour switches around a motor make it go both ways. An L293D on a breadboard: the truth table, braking against coasting, back EMF, and why half the PWM is not half the speed.
    3. A servo: an angle, not a speedA hobby servo is a motor, a gearbox, a potentiometer and a control loop in one box. Drive it with a pulse width, follow a slider, and learn why it needs its own power.
    4. A stepper on an A4988: STEP and DIRA NEMA 17 moves in exact steps with no sensor at all. Two wires from the Uno, microstepping from three pins, the current limit you set with a screwdriver, and how a stepper misses steps.
    5. An encoder: measure what the motor really didA gear motor with a Hall encoder on an L9110S pumps an exact dose: count pulses on an interrupt, work out speed from them, and slow down before the mark so it stops on it.
    Every lesson in the course
  2. Step 2 · 8 lessons · 6 h

    Build a claw machine

    A build to finish with: steppers in a real claw machine.

    Build a real arcade claw machine piece by piece, from one stepper motor to coins, a clock, a win sensor, lights and sound.

    Every lesson in the course
Keep going

Guides and tools on the same subject

Track

Embedded track

Arduino, ESP32, Raspberry Pi Pico and STM32: pins, timing, buses, motors, WiFi, registers and debugging, every lesson checked on a simulated board.

See the whole track
Questions

Questions people ask

Can I connect a motor straight to an Arduino pin?

No. A pin can only supply a few tens of milliamps, and a motor needs far more and kicks back when it stops. A driver or a transistor sits between them, which the first lesson explains.

What is the difference between a servo and a stepper?

A servo goes to an angle you ask for and holds it. A stepper turns a counted number of steps, which suits positioning over many turns, like a 3D printer axis.

Which stepper driver does the course use?

The A4988 with STEP and DIR, the same driver used on many 3D printers and CNC machines.