Pathfinder 16-Way (Line16) × SPIKE × MBC Blocks website
Interactive tutorialSPIKE
First time? Try the interactive tutorial in your browser first, then follow the steps below with your hub.
This page covers MBC SPIKE Blocks website only: how to set it up for the Pathfinder 16-Way (Line16) on SPIKE Prime / Robot Inventor, how to read every value, the commands it supports and examples. Use the switcher above to change product, host or software.
Setup
What you need
- Sensor: Pathfinder 16-Way (Line16) (SPIKE edition).
- Hub: SPIKE Prime or Robot Inventor.
- Computer: open the website in Chrome. Nothing to install.
- Hub firmware: must be switched to Pybricks firmware first (step 2 below, done from the website).
Install the software
- Open the MBC SPIKE Blocks website (blocks with a Chinese interface, nothing to install).
- Switch the firmware: top menu "SPIKE Hub → Install/Update Pybricks firmware", follow the screen, about 3 minutes. The website flashes Pybricks v4.1.0.
- To go back to the official LEGO App later, switch back to the original LEGO firmware with the SPIKE App.
Make the software see the sensor
No library needed: the MBC sensor blocks are built into the website, one block per value.
- To open an example: top menu "File → Open" (or press Ctrl+O) → pick the downloaded
.abp. - The Blocks website reads more data than the official App (no need to split numbers yourself), but example 6, marked "Pybricks only", uses a new mode that the Blocks website cannot read either.
Wiring
- Plug the sensor into hub port C with the cable (any of A~F works; choose the same port in the blocks).
- Latch up, push the plug in gently.
- When the hub is on, the light on the sensor comes on.
Calibrate first (only once)
The Pathfinder has to "learn" the black and white of your mat before its numbers are right. Calibration is stored in the sensor and survives power-off (until you change mats).
- Plug in the sensor and turn the hub on (the sensor lights come on).
- Hold the calibration button for about 0.5 s, then release it (do not keep holding it; holding it keeps restarting calibration).
- When the green calibration LED (next to the button) lights up, sweep the sensor back and forth between the black line and the white floor within 5 seconds. All 16 sensing points must pass over the darkest black line and the brightest white area.
- Keep the sensor 3~12 mm above the surface while sweeping; higher reads poorly.
- The green LED goes off = calibration done, saved in the sensor automatically.
How do I know it worked? On the white floor the "line width" is 0; on a normal black line it is 3~5.
First test
- Connect the website to the hub (the hub must be running Pybricks firmware).
- Open the
.abpof example 1 on this page and press Run. - If the number changes with what is in front of the sensor, everything is connected.
FAQ
- The website can't connect to the hub? The hub still has the original LEGO firmware: do step 2 of "Install the software" to switch to Pybricks firmware.
- The official App can't connect any more? The hub now runs Pybricks firmware: switch back to the original LEGO firmware with the SPIKE App.
- Nothing happens when I plug it in? Check in order: cable firmly in → another port → another cable → another hub.
Reading values
The hub needs Pybricks firmware. The MBC Blocks website reads mode 9 of the sensor (all values in one read).
line position linePos
| Range | Meaning |
|---|---|
-16~+16 |
which channel the line is under: −16 (far left) to +16 (far right), 0 = centre; seen from behind the robot, negative = left (normally ±15; ±16 only for 200 ms after the line leaves the outermost channel) |
Add this sensor's blocks on the MBC Blocks website and use the "line position" block; on the hub it runs this Pybricks code (mode 9):
from pybricks.iodevices import PUPDevice
from pybricks.parameters import Port
dev = PUPDevice(Port.A) # sensor on port A
w = dev.read(9)[4]
linePos = (w & 0xFF) - 16 # line position(lo byte)fine position linePosFine
| Range | Meaning |
|---|---|
-100~+100 |
sub-channel position: −100 to +100, 0 = centre, negative = left (same sign as line position) |
Add this sensor's blocks on the MBC Blocks website and use the "fine position" block; on the hub it runs this Pybricks code (mode 9):
from pybricks.iodevices import PUPDevice
from pybricks.parameters import Port
dev = PUPDevice(Port.A) # sensor on port A
w = dev.read(9)[5]
linePosFine = (w & 0xFF) - 100 # fine position(lo byte)line width lineWidth
| Range | Meaning |
|---|---|
0~16 路 |
number of channels on the line, 0~16; 0 = no line |
Add this sensor's blocks on the MBC Blocks website and use the "line width" block; on the hub it runs this Pybricks code (mode 9):
from pybricks.iodevices import PUPDevice
from pybricks.parameters import Port
dev = PUPDevice(Port.A) # sensor on port A
w = dev.read(9)[4]
lineWidth = ((w >> 8) & 0xFF) # line width(hi byte)line segments groupCount
| Range | Meaning |
|---|---|
0~8 |
number of separate line segments: 0 = lost, 1 = one line, ≥2 = fork / crossing |
Add this sensor's blocks on the MBC Blocks website and use the "line segments" block; on the hub it runs this Pybricks code (mode 9):
from pybricks.iodevices import PUPDevice
from pybricks.parameters import Port
dev = PUPDevice(Port.A) # sensor on port A
w = dev.read(9)[5]
groupCount = ((w >> 8) & 0xFF) # line segments(hi byte)line bitmap bitmap
| Range | Meaning |
|---|---|
0~65535 bit |
bit0 = channel 1 (left) … bit15 = channel 16; 1 = that channel sees the line |
Add this sensor's blocks on the MBC Blocks website and use the "line bitmap" block; on the hub it runs this Pybricks code (mode 9):
from pybricks.iodevices import PUPDevice
from pybricks.parameters import Port
dev = PUPDevice(Port.A) # sensor on port A
bitmap = dev.read(9)[6] # line bitmapchannel 1~16 reflect light
| Range | Meaning |
|---|---|
0~100 |
calibrated reflect of channel 1 |
Add this sensor's blocks on the MBC Blocks website and use the "channel 1~16 reflect" block; on the hub it runs this Pybricks code (mode 9):
from pybricks.iodevices import PUPDevice
from pybricks.parameters import Port
dev = PUPDevice(Port.A) # sensor on port A
words = dev.read(9)[0:4]
light = []
for w in words:
for k in range(4):
light.append((w >> (4 * k)) & 0x0F) # low bits firstNot readable here:last exit direction, threshold, calibrations done. Use Arduino / mBlock / micro:bit for these.
Commands
This software cannot send commands (neither the official SPIKE App 3 nor Pybricks' built-in ColorSensor blocks can). To send commands use Pybricks + the MBC library; you can also calibrate with the button on the sensor.
Examples
Example 1: See the black line
What this example does: the hub display keeps showing the line position (-16 to 16). Slowly move the black line from left to right and the number goes from negative to positive.
What you need
- 1 SPIKE hub
- 1 Pathfinder 16-Way (calibrated)
- A sheet of white paper with a black line drawn on it (or a competition mat)
How to connect: Pathfinder on port C.
Download the program
| MBC Blocks website |
|---|
| ex01_show_position.abp |
🟦 Blocks on the MBC Blocks website

Step by step through the program
- Repeat forever: the blocks inside keep running until you press stop.
- Read the line position: in the official App it is "reflected light minus 16"; the MBC Blocks website and Pybricks have "line position (-16~16)" directly.
- Show it on the display: the official App uses the "write" block, the MBC Blocks website uses "show number on display", and Pybricks uses
hub.display.number(). - Wait 0.2 seconds: lets the number sit still long enough for your eyes to read it.
What you should see
- Line right under the sensor: the display shows around 0 (-2 to 2 all count as center).
- Move the black line to the left: the number goes negative, closer to -16 the farther left you go.
- Move it to the right: it goes positive, closer to 16 the farther right you go.
Common problems
- The number is stuck at 0 and never changes? → Run example 2 first: if the light is still green on white paper, every point thinks it sees black, meaning the sensor is not calibrated yet; go back to "calibrate" above.
- Left and right are swapped? → First make sure the sensor is not mounted upside down (the side with the components must face down, toward the floor). If it is mounted correctly and still reversed, swap the sign of the "turn left" and "turn right" numbers in the later examples.
- The official App shows 16 instead of 0? → You forgot to "subtract 16".
Example 2: Black line alarm
What this example does: when it sees the black line, the hub's center light turns green; when it can't find the line, the light turns red and the hub keeps beeping.
What you need: same as example 1.
How to connect: Pathfinder on port C.
Download the program
| MBC Blocks website |
|---|
| ex02_line_alarm.abp |
🟦 Blocks on the MBC Blocks website

Step by step through the program
- Read the line width: in the official App use the "color" block; what it returns is the line width.
- If line width > 0 then…: any of the 16 sensor points is on the black line → green light.
- Else…: line width is 0, meaning not a single point is on the line → red light and a beep.
- Wait 0.1 seconds, then check again.
What you should see
- Sensor on the black line: green light.
- Move it onto the white floor: red light + nonstop beeping.
Common problems
- Always green, even on white paper? → Not calibrated yet (every point is being read as black).
- How do I pick the light color in the official App? → Click the color dot on the "set Power Button light to" block to change it.
Example 3: Which side is the junction on (16-Way only)
What this example does: the 16-Way's sensor points are spread wide and packed densely, so at a junction it can tell "where the big black patch is". The hub display tells you:
- A normal line → ⬆
- A branch on the left (T-junction going left) → ⬅
- A branch on the right (T-junction going right) → ➡
- A crossroads → +
- No line found → ✕
What you need: same as example 1, plus three kinds of junction drawn with black tape or a marker: a "T going left", a "T going right", and a "crossroads".
How to connect: Pathfinder on port C.
Download the program
| MBC Blocks website |
|---|
| ex03_junction_side.abp |
🟦 Blocks on the MBC Blocks website

Step by step through the program
- First read the line position and line width and store them in two "variables" (a variable = a box with a name that can hold one number).
- If line width = 0 → show ✕ (no line found; the line position is not reliable right now, so this check comes first).
- Else, if line width < 6 → just a narrow strip, a normal line → show ⬆.
- Else (line width 6 or more = the black got much wider, so you are at a junction), look at the "line position", which is the center of that black patch:
- line position < -3: the black is off to the left → branch on the left → ⬅
- line position > 3: the black is off to the right → branch on the right → ➡
- Neither: the black is dead center, equally wide on both sides → crossroads → +
What you should see: slowly push the sensor across the three junctions. Passing a T going left flashes ⬅ for a moment, a T going right flashes ➡, a crossroads flashes +, and the rest of the time it shows ⬆.
Common problems
- Always ⬆, junctions are never recognized? → Push it more slowly; or the branch line is too thin, so change "6" to 5.
- Normal curves get treated as junctions? → The line is too wide; change "6" to 7.
- Why is there no "+" symbol in the official App? → The official App uses a hand-drawn 5×5 picture (one horizontal and one vertical bar through the middle); the MBC Blocks website and Pybricks show the "+" character directly.
- How do I change the picture in the official App? → Click the little grid image on the "turn on" block and light up whichever pixels you want.
Example 4: The simplest line following
What this example does: the robot follows the black line on its own. Line on the left → turn left; line on the right → turn right; line in the center → go straight.
What you need
- Everything from example 1, plus
- A two-wheel robot car (two motors as wheels)
- A closed loop of black line (about 2 cm wide, no sharp turns)
How to connect
- Pathfinder on port C, mounted at the front of the car, about 0.5 to 1 cm above the floor
- Left wheel motor on E, right wheel motor on F
Download the program
| MBC Blocks website |
|---|
| ex04_simple_follow.abp |
🟦 Blocks on the MBC Blocks website

Step by step through the program
- Tell the hub where the wheels are: in the official App it is "set movement motors to E+F"; on the MBC Blocks website and in Pybricks it is "drive base: left wheel E, right wheel F".
- Set the speed: 30% in the official App; 100 mm per second in the other two. Start slow, and speed up once it works.
- Repeat forever: read the line position.
- If line position < -2 (line on the left) → turn left while driving.
- Else if line position > 2 (line on the right) → turn right.
- Else (-2 to 2) → go straight.
What you should see: the car follows the line, wobbling left and right as it goes (that is normal; example 5 improves it).
Common problems
- It shoots off right away and gets farther and farther from the line? → The turn directions are reversed: swap the sign of the two turn numbers (official App: swap -40 and 40; the other two: swap -60 and 60).
- The car drives backward? → The motors are mounted the opposite way from LEGO's standard car. Official App: mount the motors the same way as LEGO's "Driving Base" model; MBC Blocks website: in the "drive base" block, flip the "forward" direction of both the left and right wheels; Pybricks: change the left wheel to
Direction.CLOCKWISEand the right wheel toMotor(Port.F, Direction.COUNTERCLOCKWISE). - It overshoots and runs off on sharp turns? → Lower the speed.
- Why is the center -2 to 2? → The 16-Way has finer steps, so the number moves as soon as the line is slightly off; leaving a little margin keeps the car from twitching back and forth all the time.
Example 5: Smooth line following + stop at the crossroads
What this example does: follows the line using "turn as much as you are off the line", which is smoother than example 4; when it reaches a crossroads (nearly the whole row of sensor points is on black), it stops and beeps. It does not stop at T-junctions; it keeps driving straight through.
What you need: same as example 4, and the black line needs one crossroads.
How to connect: Pathfinder on port C; left wheel motor on E, right wheel motor on F.
Download the program
| MBC Blocks website |
|---|
| ex05_smooth_follow_stop.abp |
🟦 Blocks on the MBC Blocks website

Step by step through the program
- Read the fine line position (-100 to 100): in the official App it is "raw red minus 100".
- Read the line width.
- If line width ≥ 11 (the official App writes it as "line width > 10", same meaning) → crossroads: stop → beep → end the program.
- Else → turn amount = line position × a number (0.5 in the official App, 1.5 in the other two). The farther off the line, the harder it turns; slightly off means only a slight turn, so it doesn't wobble left and right.
What you should see: the car glides smoothly along the line, drives through T-junctions without stopping, and stops with a beep at the crossroads.
Common problems
- Still wobbling left and right? → Make "the multiplier" a bit smaller (for example 0.5 → 0.3).
- Can't keep up on turns and runs off the line? → Make "the multiplier" a bit bigger, or lower the speed.
- Didn't stop at the crossroads? → The car is too fast and shot straight through it; lower the speed, or change "11" to 10.
- Stopped at a T-junction before reaching the crossroads? → The line is too wide; change "11" to 12 or 13 (the maximum is 16).
- The official App version never stops at the crossroads? → In our 2026-10 hub tests, the Education SPIKE App 3 dashboard showed NaN for the "color" block once the width went above 10, and we are still re-testing the 16-way crossroads stop in blocks (on the same hub, the official App's Python reads width 16 and stops). In the home edition (Robot Inventor) "color" tops out at 10, so always use "> 9" there. Swap example 1's "reflected light minus 16" for "color", put the sensor on the crossroads and watch the number on the display; if it only goes up to 10, change example 5's "> 10" to "> 9".
- Can't find the "raw red" block in the official App? → Opening the file should automatically add the "More Sensors" block category; if it is missing, click the "+" at the bottom-left of the block palette and add "More Sensors".
More questions
- The hub does not detect the sensor? Unplug and replug, wait 2 s, try another port. The official app shows it as a colour sensor — that is expected.
- Can I use the official app and Pybricks on the same hub? One firmware at a time: Pybricks and the MBC Blocks website need Pybricks firmware, the official app needs LEGO firmware; you can switch back any time with the SPIKE app.
Still stuck? Contact us with your software and a screenshot of the program.
Downloads
- MBC SPIKE Blocks website (online, nothing to install)
- Download centre (libraries, firmware, catalogue for every product)
Sources
- Host and software list:
_build/guides.json - Values and commands:
_build/protocol/line16.json(single source of truth) - Setup:
_build/guides/software/spike-mbcblocks.en.md、_build/guides/product/line16/spike-mbcblocks.en.md - Examples:
sensors/line16/spike-examples.md