Import the library
The first thing in a block program is a red "from … import …" block under the yellow "set up" block. It tells Pybricks to use the EXP6 library. With LEGO motors and sensors only, this one is all you need; with MBC sensors you also import a product file (see "MBC sensors on the EXP6" below).
- Download the library (save the file and keep its name): MBC_exp6_obj_Lib.py. The file name is
MBC_exp6_obj_Lib.py. - In Pybricks Code, click "Import a file" in the file panel on the left and import it into the same project. Do not rename the file.
- Click "+" to add a new file and choose to write it with blocks.
- Drag the red "from … import …" block out of the block list and attach it under "set up". Choose
MBC_exp6_obj_Libin the first box andMBC_EXP6in the second.
Download block files (complete examples): ex01 one turn, ex02 three motors, ex03 light switch, ex04 button control, ex05 square. In Pybricks Code click "Import a file" and keep it in the same project as MBC_exp6_obj_Lib.py; it opens as blocks. The examples wait, so they use multitask (true) and add one more block, "from MBC_exp6_obj_Lib import run_task", which sends the heartbeat while waiting.