By Kevin McAleer, 5 Minutes
Page last updated November 24, 2026

Motors are what turn a pile of electronics into a robot. You have probably wired one up from a tutorial, copied some pin numbers, and watched a wheel spin. This course is about understanding why it worked, so that when a motor stutters, a Pico resets, or a driver gets hot, you know exactly where to look.
We cover the three motors you will meet in almost every robot: the humble DC motor, the hobby servo, and the stepper. For each one you will learn how it works, how to power it safely, and how to drive it with MicroPython on a Raspberry Pi Pico.
Everything builds towards one project. Scout is a two-wheeled drive base with a servo-mounted “head”, the perfect platform for a distance sensor later on. By the final lesson Scout drives a square, spins on the spot, and looks left and right on command.
Motor classServo class, calibration and continuous rotation servosAfter completing this course, you will:
Motor, Servo and DriveBase classesEach lesson introduces one idea, shows a short piece of working code, and ends with Try it Yourself exercises and a Common Issues list. Code blocks are complete, so you can copy one and run it.
From lesson 7 onwards we save reusable code as small files on the Pico (motor.py, drive.py, ramp.py, servo.py) and import them, exactly like you would on a real project. The file name is always the first line of the listing, as a comment.
We use the same pin numbers as the MicroPython Robotics course, so the wiring will feel familiar:
| Pin | Used for |
|---|---|
| GP0, GP1, GP2 | Left motor: IN1, IN2, ENA (PWM) |
| GP3, GP4, GP5 | Right motor: IN3, IN4, ENB (PWM) |
| GP10 | Servo head |
| GP14, GP15 | Wheel encoders (lesson 14) |
| GP16 to GP19 | Stepper IN1 to IN4 (lesson 13) |
If you use a DRV8833 instead of an L298N it has no enable pins, so GP2 and GP5 stay unused and the speed PWM goes on the IN pins. Lesson 5 shows both wirings.
Teachers: this course suits learners aged about 11 and up who have done a first Pico course, and it works well in groups of two or three with one robot each. Allow 30 to 45 minutes per lesson, and two sessions for the Scout project in lesson 15. Per group you need a Pico, a motor driver, two TT motors on a chassis, a servo and a 4xAA battery pack (alkaline or NiMH is the safest choice for a classroom). The stepper in lesson 13 and the encoders in lesson 14 are optional. Lessons 1 to 4 and the code-only parts of 6, 8, 9 and 10 can be read and discussed with no hardware at all, and the pure-Python maths functions run in Thonny on a Pico with nothing attached. Keep batteries out of boards between sessions, and run robots on the floor, not on desks.
Take it slowly, and do not worry if a wheel spins the wrong way the first time. Every robot builder has swapped a pair of wires and laughed about it.
This course assumes you have finished:
Ready? Let’s meet the motors.
Comments