MBC Pathfinder 16-Way × MBC SPIKE Blocks website

Read the Pathfinder 16-Way with the MBC Blocks website in three steps

On the MBC SPIKE Blocks website, you do not import a library for the Pathfinder 16-Way. First, inside "開機時執行一次" (run once at start), tell the website which port the sensor is on. Then add the main loop. Finally, put the reading blocks into the main loop. Work through the steps on the left and the blocks on the right grow with you. These block pictures were built and exported straight from the website, so they look exactly like your screen.

The website's blocks are in Chinese. Every block on this page comes with its English meaning in brackets, so you can match it with what you see on screen.

The website is free and needs no login. The hub needs Pybricks firmware (the website's "SPIKE 主機" (SPIKE hub) menu can install it for you).

1

Set up: which port the Pathfinder 16-Way is on

The first thing in the program is a "○ 埠 接 MBC 循行者16路" (port ○ has the MBC Pathfinder 16-Way) block under the yellow "開機時執行一次" (run once at start). Then the website knows that port has the Pathfinder 16-Way.

Which port is the sensor on?
  1. Open the MBC SPIKE Blocks website and press "+" to start a new program.
  2. In the block categories on the left, click "MBC 感應器" (MBC sensors) → "循行者16路" (Pathfinder 16-Way). The first block is "○ 埠 接 MBC 循行者16路".
  3. Attach it under "開機時執行一次" and pick C in the drop-down.
2

Add the main loop

You need to read the sensor again and again, so you need the yellow "主迴圈(一直重複)" (main loop, repeat forever). First put a "等待 100 毫秒" (wait 100 ms) block inside. Then it reads every 0.1 seconds, not too fast.

  1. From "控制" (Control), drag out "主迴圈(一直重複)" and place it in the empty space below the setup block (it does not need to snap on).
  2. Then drag a "等待 100 毫秒" block into the main loop.

The program the website makes goes into a multitasking (async) structure by itself. You do not need to choose it or write await.

3

Use the reading blocks

"MBC 感應器 → 循行者16路" has 18 more reading blocks (every function in the Pybricks library). Each block has a port drop-down in the middle. Pick the same port as in step 1 (C). Click a function and the blocks and output change to its example.

Sensor simulator (looking forward from behind the robot): drag the black line and watch the output on the right change

The simulator is only a sketch: the conversion is simplified, so a real sensor may differ by one or two steps. The number in each circle is the light value of that channel (0 = black, 15 = white). Red ring = that channel counts as on the line.

Example for each reading block

18 reading blocks, each with a set of blocks you can copy (port C). Press "Try it" to jump to step 3. The blocks and output on the right change to that example.

Things to know

  1. Use only one setup block. Each port can be set up only once. The port on the reading blocks must match the setup block. If you pick the wrong port, the website warns you before downloading.
  2. No library to download. When the website downloads your program, it sends the Pathfinder 16-Way reading code to the hub too.
  3. Same functions as the Pybricks library: everything in MBC_line16.py has a block here (bin_raw / bitmap = "16 路黑白值" (16-channel black/white value), ir_ch = "第 N 路光值" (light value of channel N)), and the values are the same. Unplugging does not stop the program: if the sensor cannot be read, you get the last value. The terminal shows one warning line in Chinese and English (MBC: Port C 讀不到感應器,先回傳上一次的值 / no sensor, using the last value). Use "感應器有接好" (sensor connected) to check if it is connected. Each channel's light value is 0 to 15, not 0 to 100.
  4. Lost line, junctions and direction: when the line leaves completely, line position gives the side where it left (−16 / +16, −100 / +100). To check "really no line", use "有偵測到線" (line found) or line width equals 0. "遇到路口" (at a junction) is "yes" only when the sensor sees two separate pieces of line (a fork). At a crossroads the whole row is black. That is one piece, so the block gives "no". For a crossroads, use "line width ≥ 11". Stand behind the robot and look forward: a line on the left is negative, a line on the right is positive. Channel 1 is on the far left.