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

Ahoy there makers! By the end of this lesson you will be able to describe the robot we are going to build, check you have the right kit, and know how the pins on the Pico will be used throughout the course.
Robots don’t have to be complicated. With a Raspberry Pi Pico, MicroPython and a handful of parts you can build a two-wheeled robot that drives, sees obstacles, follows a line and takes orders from your phone. Kev made a video asking whether MicroPython can handle real robotics, so watch it first, then let’s build.
This course goes beyond blinking LEDs. You will learn how a motor driver lets a tiny microcontroller push big motors around, how sensors turn the real world into numbers your code can act on, and how to join the two so the robot can decide things for itself. Every lesson adds one idea to the same robot, and every program is complete, so you can save it to your Pico and run it.
Which board? The code is written for the Raspberry Pi Pico (RP2040) and works unchanged on the Pico W, and on the Pico 2 as far as the standard machine calls go. Only the Wi-Fi lesson needs a Pico W (or Pico 2 W).
flowchart LR
A["Motors and driver"] --> B["Two-motor drive"]
B --> C["Sensors: line and distance"]
C --> D["Build the chassis"]
D --> E["Servo scanner"]
E --> F["Bluetooth and Wi-Fi"]
F --> G["Autonomous behaviour"]
G --> H["Your own robot"]
robot.pyAfter completing this course, you will:
You should be comfortable saving and running a MicroPython program and using Pin. If not, start with Learn MicroPython - The basics and GPIO Mastery. To understand motors in more depth, Motors and motor drivers goes further than we do here.
Each lesson opens with an objective, teaches one idea, and ends with Try it Yourself exercises, a Common Issues list and a short quiz. Wiring is given as tables, because a table of pin numbers is easier to check than a photo.
Here is the whole robot’s pin plan. Every lesson uses these pins, so you can keep one wiring all the way through. The pins are our choice, not a rule, so if one is taken in your build, change the number in the code.
| Part | Signal | Pico GP pin | Physical pin |
|---|---|---|---|
| L298N motor A (left) | IN1 | GP0 | 1 |
| L298N motor A (left) | IN2 | GP1 | 2 |
| L298N motor A (left) | ENA (PWM) | GP2 | 4 |
| L298N motor B (right) | IN3 | GP3 | 5 |
| L298N motor B (right) | IN4 | GP4 | 6 |
| L298N motor B (right) | ENB (PWM) | GP5 | 7 |
| IR sensor left | OUT | GP6 | 9 |
| IR sensor right | OUT | GP7 | 10 |
| HC-SR04 | TRIG | GP8 | 11 |
| HC-SR04 | ECHO (through a divider) | GP9 | 12 |
| SG90 servo | Signal | GP10 | 14 |
| HC-05 | Pico TX to HC-05 RXD | GP12 | 16 |
| HC-05 | Pico RX from HC-05 TXD | GP13 | 17 |
Notice that the Bluetooth module sits on GP12 and GP13 rather than the more usual GP0 and GP1: those two are already driving a motor. GP12 and GP13 are a valid UART0 TX and RX pair on the Pico, so it works.
Code that you should save as a file on the Pico is named in the lesson, for example robot.py. Short snippets that are not whole programs are marked as such.
Teachers: This course suits ages 11 and up with some Python, working in pairs or threes. Allow about 45 to 60 minutes per lesson, with lessons 6 and 11 needing a double session. Each group needs one full kit (robot parts, battery pack, a laptop). With no hardware, lessons 3, 5, 7 and 10 still work as reading and maths exercises, and the Pico code can be traced on paper. Batteries are the main safety point, so read the teacher notes in lessons 2 and 6 before the first session.
Let’s get started with the simplest moving part of all, a single DC motor.
Quick quiz 1 of 3
Which board does the course need for the Wi-Fi lesson?
network module for Wi-Fi.Quick quiz 2 of 3
Why is the HC-05 Bluetooth module wired to GP12 and GP13 in this course?
Quick quiz 3 of 3
The ECHO pin of the HC-SR04 goes to the Pico through two resistors. Which is in the kit list?
Comments