Line Follower 16-ch × mBlock 5 (Makeblock edition)
The Makeblock edition of the Line Follower 16-ch plugs into an RJ25 port on mBot, Ranger, Orion or MegaPi and is read with the MBC Pro Sensors extension v2 blocks. Installation and usable ports per board: Makeblock extension.
SPIKEEV3Arduino I2CmBlockMATRIXmicro:bit
Note
Units shipped before 2026-10 use the legacy extension v1.0.0 (marked "legacy" on the download page); old and new blocks are not interchangeable.
Wiring
Sensor → mBot adapter → RJ25 port on the board (S1 = host TX, S2 = host RX). UART 38400 8N1.
Reporter blocks
| Block | Returns | Id | Meaning |
|---|---|---|---|
| Pathfinder port [port] line position | -16~+16 | 01 |
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) |
| Pathfinder port [port] fine line position | -100~+100 | 02 |
sub-channel position: −100 to +100, 0 = centre, negative = left (same sign as line position) |
| Pathfinder port [port] line width | 0~16 路 | 03 |
number of channels on the line, 0~16; 0 = no line |
| Pathfinder port [port] line segments | 0~8 | 04 |
number of separate line segments: 0 = lost, 1 = one line, ≥2 = fork / crossing |
| Pathfinder port [port] line bitmap | 0~65535 bit | 05 |
bit0 = channel 1 (left) … bit15 = channel 16; 1 = that channel sees the line |
| Pathfinder port [port] last exit direction | -16~+16 | 06 |
where the line was before it was lost: −16 to +16 (negative = left); keeps the last value |
| Pathfinder port [port] threshold | 1~99 | 07 |
reflect threshold for 'on line', 1~99, default 40 (firmware shipped before 2026-11-03: 50); set with E4 |
| Pathfinder port [port] calibration count | 0~255 次 | 08 |
number of calibrations completed since power-on (button calibrations included) |
| Pathfinder port [port] channel [1~16] reflect | 0~100 | 10~1F |
calibrated reflect of channel 1 |
| Pathfinder port [port] channel [1~16] on line? | true/false | 05 |
bit N−1 of line bitmap 05 (channel 1 = bit0, leftmost): true when that channel sees the line |
Command blocks
| Block | Id | Meaning |
|---|---|---|
| Pathfinder port [port] black line mode | E0 |
follow a black line (default); RAM only, back to the default after reset |
| Pathfinder port [port] white line mode | E1 |
follow a white line (F3 b1 = 1); RAM only, back to the default after reset |
| Pathfinder port [port] calibrate black | E2 |
store the current reading as black (sensor over the black line), ~50 ms; saved to EEPROM(F3 bit2 = 1 while running) |
| Pathfinder port [port] calibrate white | E3 |
store the current reading as white (sensor over the white surface), ~50 ms; saved to EEPROM(F3 bit2 = 1 while running) |
| Pathfinder port [port] set threshold [threshold] | E4 |
threshold 1~99 (RAM only, back to 40 after reboot); on SPIKE an out-of-range value returns failed (state 2) |
| Pathfinder port [port] 5-second auto calibration | E7 |
sweep the sensor across black line and white surface for 5 s; min/max become the references; F3 b2 = 1 meanwhile(F3 bit2 = 1 while running) |
| Pathfinder port [port] update all values | FD |
reads the whole value table into a cache (FD pack-all); reporter blocks within the next 10 ms use the cache instead of asking one by one |
Status blocks
The extension exposes each F3 bit as a boolean block:
| bit | Name | Meaning |
|---|---|---|
| b0 | ready (ready) |
always 1 |
| b1 | white line mode (whiteMode) |
1 = following a white line |
| b2 | calibrating (calibrating) |
E2/E3/E7 in progress; new calibration commands are ignored |
| b3 | line lost (lost) |
segment count = 0 |
| b4 | fork (fork) |
segment count ≥ 2 |
| b5 | mirrored (reversed) |
E9 = 1 (sensor mounted backwards, left/right mirrored) |
Packet format (for your own decoder)
| Action | Format |
|---|---|
| Read one value | 主機送 [編號] → 回 [值低][值高][編號^值低^值高] |
| Write command | 寫入命令 E0~EE:收齊參數後回 [00][00][編號] 再執行;20 ms 內沒收齊就丟棄 |
| Unknown id | [00][80][編號^0x80](= -32768) |
| Pack all (FD) | Send [FD] → reply [AA][18][24 × int16 LE][xor], xor = AA ^ N ^ all data bytes; content = this value table in ascending id order (shared ids and commands excluded). The extension fetches it once and serves blocks from a 10 ms cache. |
| Shared ids | F0 device ID, F1 protocol version, F2 firmware version, F3 status flags |
Sources and assumptions
Generated by _build/gen-reference.mjs from _build/protocol/line16.json (single source of truth, transcribed from the 2026-10-21 protocol decisions).
- B-11:細位置 02 與線位置 01 同號(負 = 左);韌體 F16:1290 註解寫反,程式碼同號(IR:11 為準)。
- B-12:E7 五秒動態校準補回(v1 的 0x20=0x01),定案表沒列。
- EV3:模式 0~2 鎖住;模式 3 原本不送 → 16 bit 位元圖;模式 4 原本不送 → 同模式 2;模式 5 ID 格式 B(共用函式)。
- SPIKE:0/5/7/9 鎖住,1
4、6 維持不動;教育版模式 0 的 16 路光值是 2-bit(玩具版 1-bit),跟 8 路的 4-bit 不同;byte 815 補 0(#65 已改,使用者保留);模式 9 排法照盤點(四路 4-bit 一個 int16,v6 = 位元圖);模式 8 v[0] 改 ID|hw[0]<<8。 - 線段數 04 範圍:定案沒寫,16 路最多 8 段(交錯壓線),採 0~8。
- mBlock 舊版:MBC_MBLOCK_LEGACY=1 時逐 byte 同 2026-10-21 統一後韌體(0x01 位置、0x02 線寬、n<<4|03 反向兩路壓一 byte、0x07 細位置 0~200),0x0B 回 1(B-1)。
- Flash:C031 硬體鎖 28 KB,I2C 版餘 848 B;不夠時照 B-17 順序瘦身,JSON 不受影響。
- Block wording follows the v2.0.0 extension generator
build_mext.js; this page is generated from the same JSON.