The course
This is a complete first course in MicroPython on a Raspberry Pi Pico. You do not need any electronics experience. You need curiosity, patience, and a habit of pressing Run.
How the course works
The pages are listed in teaching order. Start with Start here, then work through the lessons. Each module guide ends with the problems that practise it. After lesson 6, Ten things to build puts the foundations together into small, complete projects.
The exercises are the Raspberry Pi Pico set in Practice: every problem named on these pages links to it, and the set also has console problems (input and output, no wiring) for practising plain MicroPython. Your solved problems are ticked there.
Every lesson follows the same loop:
- Predict — before you run anything, guess what the board will do.
- Build — type the program, or start from the problem's starter.
- Run — watch the board and the console.
- Test — press Run tests. Every problem has checks, and a failing one says what it saw.
- Explain — say out loud why it worked. If you cannot, that is the part to re-read.
- Remember — do the three-bullet recap at the end of the lesson, then look away and say it.
A note on mistakes. A program that does not work is not a failure; it is a measurement. The console tells you what happened, the checks tell you what was expected, and the board shows you the truth. Read those three before changing anything.
What this Pico can do
This is a real MicroPython interpreter running on a simulated Raspberry Pi Pico. The board has a 40-pin header, 3.3 V logic, and the RP2040's limits. Everything below works:
| You can | MicroPython | Lesson |
|---|---|---|
| Switch a pin on and off | Pin(n, Pin.OUT), value, on, off, toggle | 1 |
| Read a pin, with a pull-up or pull-down | Pin(n, Pin.IN, Pin.PULL_UP) | 3 |
| Measure time and sleep | utime.sleep, sleep_ms, ticks_ms, ticks_diff | 2 |
| Dim an LED, drive a servo or a buzzer | PWM(Pin(n), freq=…), duty_u16, duty_ns | 6 |
| Read a voltage | ADC(26), read_u16, read — GP26, GP27, GP28 only | 5 |
| Talk to I²C devices | I2C(0, sda=Pin(4), scl=Pin(5)), scan, readfrom_mem, writeto_mem | 7, 8 |
| Talk to SPI devices | SPI(0, sck=…, mosi=…, miso=…), write_readinto | 9 |
| Listen to a serial device | UART(0, baudrate=…, tx=…, rx=…), readline, any | 10 |
| Run code later or periodically | machine.Timer (cooperative, after sleeps) | 11 |
| React to a pin change | Pin.irq() (cooperative, checked during sleeps) | 12 |
| Draw on a 128×64 OLED | from ssd1306 import SSD1306_I2C and the display methods | 8 |
| Light the on-board LED | Pin(25) — not on the header | 1 |
What this Pico cannot do — and why
| Not available | Why | What to do instead |
|---|---|---|
| Wi-Fi and Bluetooth | This is a plain Pico, not a Pico W | Keep data on the board; print it |
| PIO (programmable I/O) | Not modelled | Use SPI, I²C or UART |
| USB devices and the hardware watchdog | Outside the simulator | Say so in the docs; do not design around it |
| Files that survive a run | There is no flash on the simulated board | Print results, or keep them in variables |
CircuitPython libraries (adafruit_…) | No package store for the Pico | Use machine, framebuf and the standard MicroPython modules |
| 16-bit register addresses on I²C | The simulated devices use 8-bit pointers | Use 8-bit registers |
Fun fact. The real RP2040 has two 133 MHz cores, 264 KB of RAM and 2 MB of flash — and it costs about four dollars. The simulator reports 133 MHz, but your program's speed is your browser's speed. That is why timing lessons use
utime, never instruction counting.
The modules
Module 1 — The foundations (lessons 1–6)
| Lesson | You will be able to | Problems to try |
|---|---|---|
| 1. Switch a pin | Make a pin high or low and explain what “high” means | First blink, The Pico’s own LED, Alternating lights |
| 2. Time and patterns | Use sleeps and ticks to make a timed pattern | Double blink, Running lights, Countdown |
| 3. Read a pin | Read a button, choose a pull-up or pull-down, and explain floating pins | Button mirror, Reaction game |
| 4. Remember state | Keep a variable across presses, debounce a button, build a small state machine | Press to toggle, Two-way switch, Short or long?, Three-mode light, Alarm panel, Servo switch |
| 5. Measure a voltage | Read an analogue voltage and map it to a useful number | Read a voltage, Night light, Sticky dimmer |
| 6. Dim and move | Use duty and frequency to control brightness, position and sound | PWM fade, Servo sweep, A steady tone, Three notes, Point where you look, Motor speed |
Module 2 — Devices (lessons 7–10)
Full guide: Devices on a bus — I²C, the OLED, SPI and UART, with worked examples and the device checklist.
| Lesson | You will be able to | Problems |
|---|---|---|
| 7. I²C: meet a sensor | Scan a bus, read and write a register | Find the sensor, Wake the sensor, Is the sensor there? |
| 8. I²C: draw on an OLED | Initialise a display and draw text and shapes | Write on the OLED, Count on the screen, Press counter on screen, A small menu, Bar graph, Sensor on screen |
| 9. SPI: read a fast ADC | Read channels of an MCP3008 | Read a channel, Two channels |
| 10. UART: listen to a GPS | Read and parse NMEA sentences | Listen to the GPS, Read the GPS type |
Module 3 — Time and events (lessons 11–12)
Full guide: Time and events — timers, pin interrupts and the cooperative model.
| Lesson | You will be able to | Problems |
|---|---|---|
| 11. Timers | Run a callback periodically or once, and explain why it waits for a sleep | Blink with a timer, One-second glow |
| 12. Pin interrupts | React to a pin edge without a busy loop | Use the patterns from Press to toggle and Short or long? |
Module 4 — Real loads (lessons 13–14)
Full guide: Real loads — relays, MOSFETs, the L298N and motor safety.
| Lesson | You will be able to | Problems |
|---|---|---|
| 13. Switch a real load | Use a relay or a MOSFET to switch a 5 V lamp, fan or pump | Relay lamp, One relay, two lamps, Fan thermostat, Transistor switch, Night lamp, Plant waterer |
| 14. Motors | Drive a DC motor forward, backward and at a speed with an L298N | Motor forward, Motor reverse, Forward and reverse, Motor speed |
Module 5 — Capstone (lesson 15)
Full guide: Build a system — planning, integration order, three worked capstones and what “good” looks like.
| Lesson | You will be able to | Problems |
|---|---|---|
| 15. Build a system | Combine a sensor, a display and an actuator into one program | Kitchen timer, Reaction game, Doorbell, Plant waterer, Tilt alarm, Colour mixer, Follow the light |
How your work is judged
- Run shows you the board and the console. Nothing is graded here.
- Run tests runs the problem's checks in your browser. A failing check says what it saw: “switched on 0 times”, “was 0.00 at 1.20 s”, “there is no OLED on the board”.
The checks are written to be honest: a check that passes for the wrong reason is a bug in the problem, and we fix it. If a check surprises you, read its detail before changing your code.
The rules of the bench
- 3.3 V logic. A GPIO is not 5 V tolerant. 5 V on a pin damages it for the rest of the run.
- GP26, GP27 and GP28 are the only ADC pins.
- GP25 is the on-board LED, not a header pin. GP23 and GP24 are not on the header either.
- Wire as many parts as the lesson needs. A practice problem may set a parts budget; the Sandbox and Lab have none.
- The board keeps running after
main.pyends — press Stop to power it down.
A study plan that works
| When | What |
|---|---|
| Before a lesson | Read its “You will be able to” line; try to predict the diagram |
| During | Type the code yourself; do not paste. Change one thing at a time |
| After | Explain the program to someone (or a rubber duck) in three sentences |
| Next day | Rebuild the program from memory; check the three-bullet recap |
| End of module | Pick one problem you have not tried and solve it without the starter |
The word bank has every term in plain language.
Next: Start here · Lesson 1: Switch a pin