MBC Pathfinder 8-Way (Line8) × MBC SPIKE Blocks website

Read the Pathfinder on the MBC Blocks website in three steps

On the MBC SPIKE Blocks website, you do not need to import a library for the Pathfinder. First, inside "run once at start", tell the website which port the sensor is on. Then add the main loop. Last, put a reading block into the main loop. Follow 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 the same as on the website.

The website's blocks are in Chinese. Every block below comes with an English explanation. We write each block as "Chinese name (English meaning)", so you can find it on the 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 has the Pathfinder

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

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) → 「循行者8路」 (Pathfinder 8-Way). The first block is 「○ 埠 接 MBC 循行者8路」.
  3. Attach it under 「開機時執行一次」 (run once at start), and pick C in the drop-down.
2

Add the main loop

You read a sensor again and again, so you need the yellow 「主迴圈(一直重複)」 (main loop, repeats for ever). First put a 「等待 100 毫秒」 (wait 100 ms) block inside it. Then it reads every 0.1 s, not too fast.

  1. From 「控制」 (Control), drag out 「主迴圈(一直重複)」. Put it in an empty spot below the set-up blocks (they do not need to snap together).
  2. Drag a 「等待 100 毫秒」 (wait 100 ms) block into the main loop.

The program the website makes is put into a multitasking (async) program for you. You do not choose it, and you do not write await.

3

Use a reading block

「MBC 感應器」→「循行者8路」 also has 18 reading blocks (everything the Pybricks library can do). Each one 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 from behind the robot): drag the black line and watch the output on the right

The simulator is only a picture. The maths is simpler than the real thing, so a real sensor may be off by a channel or two. Light value 0 = black, 100 = white. A red ring = that channel sees the line.

An example for every reading block

18 reading blocks. Each one has an example you can copy (port C). Press "Try it" to jump to step 3. The blocks and output on the right change to that example.

Good to know

  1. You need only one set-up block. Each port can be set up once. The reading blocks must use the same port as the set-up block. If you pick the wrong port, the website warns you before it downloads.
  2. No library download. When the website downloads your program, it also sends the Pathfinder reading code to the hub.
  3. Same as the Pybricks library: every function in MBC_line8.py has a block here (bin_raw / bitmap = 「8 路黑白值」 (8-channel black/white value), ir_ch = 「第 N 路光值」 (light value of channel N)), and the values are the same. Unplugging does not stop the program: when the sensor cannot be read, you get the last value. Use 「感應器有接好」 (sensor is connected) to check the cable. In the Python view, the website's Chinese comments are shown in English.
  4. When the line is lost: when the line leaves the sensor completely, the line position gives the side where it left (−8 / +8, −100 / +100). To check "I really cannot see a line", use 「有偵測到線」 (line found) or line width equals 0.
  5. Direction: stand behind the robot and look forward. Line on the left = negative, line on the right = positive. Channel 1 is on the far left.