Paste the reading helper
A SPIKE App Python project is a single file and cannot import your own .py, so paste the whole "reading helper" at the very top (its first lines say so: copy it as is). Without it the hub does not know Line16App and stops with NameError.
- Open the LEGO SPIKE App (Education, yellow SPIKE Prime hub), create a project and choose "Python".
- Paste the program marked ① on the right at the top (only the first helper line shows; press "Show helper" to see it all, and "Copy program" always copies everything). The helper alone: MBC_line16_App_helper.py (open it in a text editor and copy all; the file has Chinese and English comments).
- Plug the Pathfinder into any port A–F; the hub powers it. The App sees it as a color sensor, so there is nothing to install.
The helper reads three of the App's color sensor values and converts them the same way as the SPIKE App blocks page:
| App value | Holds | Helper function |
|---|---|---|
Reflection reflection() | line position + 16 | pos16(): minus 16 → −16 to +16 |
Raw red rgbi()[0] | fine position + 100 | pos100(): minus 100 → −100 to +100 |
Color color() | line width (channels on the line) | width(): as is → 0 to 16, 0 = no line |