Start the course. It is a beginner course: if you can type a line of Python, you can follow it.
The console
Every lesson uses the same little console, so the wiring never changes:
- A Raspberry Pi Pico running the official MicroPython firmware.
- A 128 x 64 SSD1306 OLED on I2C0: SDA on GP4, SCL on GP5.
- Button A on GP15 and button B on GP14, each to ground, read with the Pico's pull-ups.
- A piezo on GP16, driven by PWM.
The driver, ssd1306.py from micropython-lib, sits in a tab beside main.py, the way Thonny copies it onto a real Pico.
Lesson by lesson
- Drawing on an OLED. Pixels, lines, boxes, text and circles, and why nothing shows until
show(). The program counts its own lit pixels, so you can predict a number and check it. - Moving a dot. The game loop: clear, draw, show, move. Bounce a ship off the walls, predict the frame it turns on, and measure your frames per second (the I2C transfer is the limit).
- Reading buttons. Pull-ups and why pressed reads 0, held versus tapped, edge detection, and the 3 ms of contact bounce that reading once a frame steps over.
- A score. Box collisions in one line, a score drawn with
%formatting, and a game over after three misses. - Random enemies. An asteroid field made of lists,
random.randint, seeds for repeatable games, three lives and levels that speed up. - Sound. PWM tones on a piezo: a start jingle, a falling crash sound, the lowest note the RP2040's PWM can make, and a tune stored as a list of pairs.
- Project: snake. Everything at once.
The finale: space snake
The screen becomes a 32 x 16 grid. The snake is a list of cells, head first: each move inserts a head and pops the tail, unless it just ate. Button A turns left and B turns right, the snake speeds up as it grows, food never lands inside it, and in the last step the edges warp you to the other side, like Asteroids. Then you add a feature of your own.
How the Pico engine differs
The Pico on the canvas boots the real MicroPython v1.29 firmware on a simulated RP2040, so the code is exactly what you would run on a real board. A few things to know:
- Timing is real. A full
oled.show()takes about 26 ms at 400 kHz, so frame rates match a real console. - Buttons bounce. Like real switches, the pushbuttons rattle for a few milliseconds. The games read them once a frame, which hides it.
- Random is repeatable. The lessons seed
randomso every run is the same. Without a seed, MicroPython seeds itself from the chip. - One core. The simulator runs one core of the RP2040, so
_threadis not available. These games never need it.
Where next
Concurrency: tasks, races and async takes the same Pico further: interrupts, asyncio and queues. MicroPython on the Pico covers the board's other parts: the ADC, PWM fades and sensors.