Source: https://mokxi.com/teachers/plans/stepper-motion-planning
Updated: 2026-11-19

Lesson plan

# Stepper motion planning lesson plan

What a printer’s firmware does between a line of G-code and two STEP pins: microsteps, trapezoid and S-curve ramps, AccelStepper, Bresenham, a G-code parser, homing and limits, and a plotter that does it all.

3 chapters, 7 lessons, about 7 hours, on the Arduino Uno R3. Every lesson runs in the browser, with nothing to install.

Start a class from this course

The unit

## Objectives and materials

### By the end, students can

- What a microstep is worth, ramps worked out and run, and the library that does it for you.
- Bresenham keeps two motors on one line, and a parser turns G-code into moves.
- Homing that brakes and backs off, soft and hard limits, and the boss: a G-code plotter.

### Materials for the whole unit

- Arduino Uno R3
- Hobby servo
- Limit switch, lever microswitch x 2
- Stepper driver, A4988
- Stepper motor, NEMA 17 x 2
- TMC2209 stepper driver

Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.

Chapter 1. About 3 h 5 min

## One axis, done right

What a microstep is worth, ramps worked out and run, and the library that does it for you.

Lesson | Time | What students do

Microsteps: what one pulse is worth An A4988 and a TMC2209 with their mode pins on the Uno. Send both the same pulses and they turn different amounts: read each chip’s table, set 1/16 and 1/64, move one microstep, and count the pulses a second each mode costs. | 65 min

- Run it
- Same pulses, two angles
- The A4988’s table
- Pulses per millimeter
- The TMC2209’s table
- One microstep
- The pulse budget

Acceleration ramps: trapezoids and S-curves Jump a NEMA 17 past its ceiling and watch it lose steps. Then work out a trapezoid, find when a move becomes a triangle, run a ramp one step at a time, and see what an S-curve costs. | 65 min

- Run it
- Hit the wall
- The trapezoid
- Short moves are triangles
- Run a ramp
- S-curves: limit the jerk
- Double the acceleration

AccelStepper: the ramp, done for you The library most Arduino machines use: moveTo and run, the recurrence that times each step, where it starts braking, what stop() really does, and the step rate an Uno tops out at. | 55 min

- Run it
- moveTo and run
- Where it starts braking
- stop() is not a halt
- The Uno’s ceiling
- A gentler machine

### Materials

- Arduino Uno R3
- Stepper driver, A4988
- Stepper motor, NEMA 17 x 2
- TMC2209 stepper driver

### Check for understanding

Each student finishes "AccelStepper: the ramp, done for you" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "A gentler machine".

Chapter 2. About 1 h 50 min

## Two axes and a language

Bresenham keeps two motors on one line, and a parser turns G-code into moves.

Lesson | Time | What students do

Multi-axis sync: Bresenham Two motors, one straight line. Step both at one rate and see the dog leg, trace Bresenham by hand, draw the line within half a step, and turn a feed along the path into a step rate per axis, capped at the limit. | 55 min

- Run it
- The naive way
- Bresenham by hand
- A straight line
- Feed is along the path
- The axis limit

G-code parsing: words, modes and checksums The plotter’s firmware reads G-code one line at a time. Split a line into words, set the position with G92, see modal motion and relative mode carry from line to line, and catch a corrupted line with a checksum. | 55 min

- Run it
- Where am I?
- Words
- Modes carry over
- Line numbers and checksums
- Say no clearly

### Materials

- Arduino Uno R3
- Hobby servo
- Limit switch, lever microswitch x 2
- Stepper driver, A4988
- Stepper motor, NEMA 17 x 2
- TMC2209 stepper driver

### Check for understanding

Each student finishes "G-code parsing: words, modes and checksums" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Say no clearly".

Chapter 3. About 1 h 50 min

## A real machine

Homing that brakes and backs off, soft and hard limits, and the boss: a G-code plotter.

Lesson | Time | What students do

Limits and homing Home a two-axis machine the way Grbl does: seek fast, brake past the switch, back off, touch slowly, pull off. Then refuse a target off the bed, and stop dead when a switch trips mid-move. | 55 min

- Seek fast, brake
- Back off, touch slowly
- Both axes
- Soft limits
- Hard limits
- A bigger bed

Boss: a two-axis plotter Put it all together on the G-code plotter: home it, drive the pen, draw a square line by line, read a ramp off every move, run a whole drawing, and make the machine faster by tuning its acceleration. | 55 min

- Home it
- Pen down
- A square, line by line
- Every move is a ramp
- Run a drawing
- Tune it faster

### Materials

- Arduino Uno R3
- Hobby servo
- Limit switch, lever microswitch x 2
- Stepper driver, A4988
- Stepper motor, NEMA 17 x 2
- TMC2209 stepper driver

### Check for understanding

Each student finishes "Boss: a two-axis plotter" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Tune it faster".

Your class

## Teach this unit as a class

Start a class from this course and its 7 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.

The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.

Start a class from this course See the demo class

More units

## Other lesson plans

Electronics basics 20 lessons, about 10 h. Embedded on the Arduino Uno 16 lessons, about 12 h. Embedded on the ESP32-C3 13 lessons, about 11 h. Embedded on the Raspberry Pi Pico 7 lessons, about 6 h. Build your own fight stick 5 lessons, about 4 h. Embedded on the STM32F411 6 lessons, about 6 h. C++ on a board 13 lessons, about 10 h. Digital logic and memory 4 lessons, about 4 h. Interactive devices on the Uno 9 lessons, about 8 h. From gates to a computer 23 lessons, about 16 h. Build a claw machine 8 lessons, about 6 h. Every unit All the courses as ready-made units, on the teachers page.
