Make your board say hello, blink a light, and ask you a question.
You do not need to know Python to begin. You will build programs by joining blocks, then see the Python that they make.
Open PyBlocks · Back to the project
| Adventure | You will learn | What you need |
|---|---|---|
| 1. Say hello | Text and running a program | Any supported board |
| 2. Make a light blink | Order, waiting, and repeating | An original Raspberry Pi Pico |
| 3. Ask a question | Input and variables | Any supported board |
| 4. Learn from a mistake | Handling an error | Any supported board |
The pictures use the English interface. You can change the language in Settings.
Bring a supported board, a USB data cable, and a computer with Chrome or Edge. A charging-only cable will not work for sending programs.
Ask a teacher or grown-up to help with the first USB connection. If your board needs MicroPython installed, use the setup notes for grown-ups at the end of this guide.
You can explore the blocks without a board. You need a board to run the program.
This screenshot shows the earlier layout. In the current editor, device controls and console output are above the Code panel.
Think of the screen as three work areas:
| Where? | What happens there? |
|---|---|
| Left: Block | Pick a category, drag blocks out, and join them together. |
| Upper right: Device | Connect, upload and run, stop, disconnect, and read console messages. |
| Lower right: Code | See or edit the Python made by your blocks. You can collapse it when not needed. |
A program is a set of instructions. Connected blocks run from top to bottom. A block that fits inside another block gives it a value, such as a message or a number.
Your mission: make the board send you a message.
Download the finished hello project if you would like to follow along with the blocks already assembled.
- Open Text in the toolbox on the left.
- Drag a print block onto the empty workspace.
- Click its text and type
Hello, PyBlocks!. - Look at Code. You should see a line like this:
print('Hello, PyBlocks!')Your blocks should look like the picture above. print sends a message to the console; it does not print on paper.
- Connect the board with its USB cable.
- In the Device panel, click Upload and run.
- With your teacher, choose the board's USB serial device in the browser window.
- Keep the cable plugged in while the program is sent.
- Look in Console output for your message:
Hello, PyBlocks!
You might also see startup messages from MicroPython. That is normal.
Replace the message with I made a program!, then upload again.
Think about it: what do you predict will happen if you connect two print blocks, one underneath the other?
Try it: make the board tell a two-line joke. Keep the question above the answer.
Click Export and keep the downloaded .json file. Give the file a name you can remember, such as my-first-hello.pyblocks.json. To use it later, click Import.
Your mission: repeat a short set of instructions.
This adventure uses the original Raspberry Pi Pico and its built-in LED. You do not need to attach a separate light or wires. Pico W and Pico 2 need different support and are not the target of this example.
Download the finished Pico blink project.
- From Loops, add a repeat block and change its number to
5. - From Pico, place an on onboard LED block inside the repeat block.
- From Timing, add Wait 500 ms underneath it.
- Add off onboard LED next.
- Add another Wait 500 ms at the bottom.
Join the four inside blocks in the same order as the picture. A wait gives you time to see the light before the next instruction runs.
500 milliseconds is half a second. 1,000 milliseconds is one second.
Before uploading, count how many times you think the light will turn on. Now upload the program to your Pico and watch it.
- Change
5to10. What changes? - Change both waits from
500to200. Is the blink faster or slower? - Make the light stay on longer than it stays off.
Think about it: why do we put a wait after turning the light off, too?
Keep the idea of show something → wait → change it → wait, but choose blocks for your board:
| Board | A version to try |
|---|---|
| micro:bit V1 or V2 | Under Micro:bit → Display, show a HEART image, wait, then show HEART_SMALL and wait again. |
| Matrix:bit | Under Display, add SSD1306 driver. Under Matrix:bit, add initialize Matrix:bit onboard OLED. Draw a short message using the shared Display blocks, refresh, wait, then clear, refresh and wait again. |
Use only the branch for the board you have. The Pico LED blocks are not for a micro:bit or Matrix:bit.
Your mission: let the board remember your answer.
Download the finished name project.
A variable is a named place to keep a value. Here, name keeps the answer you type.
- Open Variables, create a variable called
name, and drag out set name to. - From Text, put read a line of input into its value slot.
- Set the question to
What is your name?. - Add a print block underneath the set block.
- Put a create text with block inside print.
- Join the text
Hello,with a name variable block, as in the picture.
Leave a space after the comma in Hello, so your answer does not run into the greeting.
- Upload the program.
- Wait for
What is your name?in Console output. - Click the input box at the bottom of the console.
- Type a short name such as
Alex, keep the line ending set to CR, and press Enter or Send. - Look for the greeting:
What is your name? Alex
Hello, Alex
The board may echo your answer as you type or send it. The exact line layout can vary by firmware.
The program waits at the question until you answer. This is what input() does.
Ask What is your favorite animal? and make the reply start with I like .
Think about it: what value is kept in name after you answer? Would a different variable name make your animal program easier to understand?
Typing tip: on the project's ESP32 firmware, the built-in line editor accepts ordinary ASCII characters. Use a name such as Alex for this activity; Chinese characters typed into native input() are filtered by that firmware. Programs can still display Unicode output.
| Button | What to expect |
|---|---|
| Stop | Ask the running program to stop. You may see KeyboardInterrupt; you have not broken the board. |
| Soft reset | At the >>> prompt, restart the saved program so it can ask its question again. Interrupt a running program first. |
| Clear | Clear messages from the screen. The program itself keeps running. |
Press ↑ / ↓ in the input box to revisit recently sent text. Use Connect in the Device panel if the console is disconnected. Keep CR selected while following these activities.
Your mission: help a program respond when an answer is not what it expected.
An error means the program could not follow an instruction. Errors are clues. Programmers use them to learn what needs changing.
This activity starts from the input and exceptions project. Ask your teacher to help download and open it. It is longer than the name program, so you do not need to build it from memory.
- Upload the example and wait for
Integer>. - Type
42and send it. The program should accept the number. - At the next question, type
helloand send it. - Look for an error message and
Finished this attempt. - Try another number. The program is still ready for you.
An integer is a whole number, such as 0, 7, or 42. The word hello cannot be turned into one.
Find the exception-handling blocks under Logic:
| Part | Read it as… |
|---|---|
| try | “Try to turn this answer into a number.” |
| catch ValueError | “If the answer cannot become a number, show the error.” |
| finally | “Finish this attempt, whether the answer worked or not.” |
The example uses an int Python-call block to turn text into a whole number. You can leave that block as it is while you explore the error-handling parts.
Change one thing: change the catch body's printed message to Please type a whole number..
Think about it: why is it helpful for the program to ask again after a mistake?
Click Stop when you want to stop the repeating questions.
Choose a small challenge:
- Robot introduction: print three messages about an imaginary robot.
- Light pattern: make a Pico blink two quick times, then pause.
- Friendly greeter: ask a question and include the answer in a new sentence.
- Helpful number reader: keep asking for a whole number after an invalid answer.
Change one thing at a time. Predict what will happen, run the program, and compare what you saw with your prediction.
| What happened? | Try this |
|---|---|
| Nothing appears in the console | Check the USB cable, upload status, and connection. A charging-only cable cannot send data. |
| The board is waiting and looks stuck | It might be waiting for your answer. Read its last question and send a line with CR. |
| You cannot find the board in the chooser | Ask your teacher to check the cable, browser, USB mode, and whether another app is connected. |
| The blocks will not join | Check their shapes. A value block belongs in a value slot; instruction blocks join in a stack. |
| The program runs in the wrong order | Follow connected blocks from top to bottom. |
| The light does not blink | Check that the example matches your board and that there is a wait after both on and off. |
| You changed blocks but the old program still runs | Upload again. If Code has manual edits, ask your teacher about Use generated code. |
| You see a red error or a traceback | Read the last line with a teacher. It often tells you which instruction needs attention. |
If you need to start again, save your project first. You can reopen a finished example and try a smaller change.
The activities use the English interface on PyBlocks. English and Simplified Chinese can be selected in Settings. A supported desktop browser and HTTPS or localhost are needed for device connections.
If compatible MicroPython is already installed, start with the hello activity. Otherwise:
- Back up any board files you want to keep.
- Open Install MicroPython firmware.
- Choose a device family, then its exact model (or automatic chip/version detection where offered). Click Connect and detect.
- Select the USB device. Review the chip, capacity and matching firmware. If there is no match, change the selection or follow the official firmware link.
- Click Install firmware only after checking the result, and keep USB connected until writing and verification finish.
See the firmware installation guide for supported families, automatic detection and capacity handling.
Installation replaces existing programs and files. Program uploads write main.py and attached libraries. The original Pico requires BOOTSEL mode and WebUSB for firmware installation, then normal MicroPython mode for program uploads. Close other applications using the serial port.
Each lesson link opens a project file in the repository. Download its raw .pyblocks.json file, then select it with Import. Do not save the GitHub HTML page as the project.
Libraries attach Python modules to the project: add a package from the official micropython.org index, or upload a .py file or .zip archive and confirm the destination paths (folders such as umqtt/simple.py are kept). Libraries are deployed under the board library directory (for example /lib) before main.py. The first upload on a serial connection writes all project libraries. Later uploads on that connection reuse the files already written with matching contents. Reconnecting or modifying board files in the Files panel clears the upload record. On the next upload, files removed from the project are deleted from the board if the editor uploaded them during the current connection. Boards without directories accept only top-level modules. Some modules may already be built into your firmware. The top of the panel shows each added dependency with its version or Local label and file count. Expand it to see its paths. Use Remove beside the dependency or its package-list entry. Files shared with another dependency stay in the project.
For a TM1637 four-digit display, add tm1637 in Libraries, then use Display → TM1637 to initialize a display and show two pairs of digits with the center colon. Use two output-capable GPIOs. On Matrix:bit, P0 and P1 correspond to GPIO33 and GPIO32, respectively. The standard driver uses machine.Pin and requires compatible MicroPython firmware. Import the Matrix:bit TM1637 example to count minutes and seconds from 00:00 with a blinking colon. Connect CLK to P0 and DIO to P1. Press A to pause or resume, and B to reset to 00:00 while keeping the current running or paused state. The example includes the driver.
Export backs up blocks and attached libraries; download exports only the current Python code. Projects are automatically saved in IndexedDB under the editor URL's ID. Edit the project name in the header or open My Projects to manage them. Exported files are the portable backup. Import replaces the current workspace.
Keep Code as generated for these activities. Manual edits are preserved separately and can be replaced using Use generated code. Credentials entered in future network projects are included in exports; remove them before sharing classroom work.
When learners are comfortable with sequence, repetition, variables, and input, explore the other example projects. Wi-Fi, HTTP, MQTT, NTP, and asynchronous tasks need more setup and are better introduced as separate lessons. Networking examples currently target the supplied ESP32 firmware. See the runtime notes for firmware limits.
The editor can also be installed as a PWA for offline use after its initial assets have cached. Offline editing still needs a suitable browser for USB access, and Internet services still need a network connection.
Import the SSD1306 driver built entirely from blocks. It targets the Matrix:bit OLED (I2C 0, SCL 22, SDA 23, address 0x3C) by default and shows how to allocate a buffer, create a FrameBuffer, initialize a controller and send its pixels using ordinary functions and I2C operations. It does not require the bundled driver or a separate Python file. See FrameBuffer design and acceptance plan. Hardware verification is pending.


