This page has moved into the new guide: Pathfinder 8-Way › micro:bit › MakeCode

Line Follower 8-ch × micro:bit (MakeCode extension)

Back to Line Follower 8-ch

The universal I2C edition of the Line Follower 8-ch works with BBC micro:bit V1 / V2 through the MakeCode extension pxt-mbc-sensors v2 (which speaks MBC I2C protocol v2). Installation and hardware notes (3.3 V, power): micro:bit overview.

SPIKEEV3Arduino I2CmBlockMATRIXmicro:bit

Important

Extension v2 is not yet verified on hardware; block names follow the published release: https://github.com/contactmbcrobot/pxt-mbc-sensors

Wiring

Line Follower 8-ch × micro:bit
Sensor micro:bit
SDA(RX) P20
SCL(TX) P19
VCC micro:bit 3V (external 5 V recommended on batteries)
GND GND

Reporter blocks

Block Returns Id Meaning
line position -8~+8 01 which channel the line is under: −8 (far left) to +8 (far right), 0 = centre; seen from behind the robot, negative = left
fine line position -100~+100 02 sub-channel position: −100 to +100, 0 = centre, negative = left (same sign as line position)
line width 0~8 路 03 number of channels on the line, 0~8; 0 = no line
line segments 0~4 04 number of separate line segments: 0 = lost, 1 = one line, ≥2 = fork / crossing
line bitmap 0~255 bit 05 bit0 = channel 1 (left) … bit7 = channel 8; 1 = that channel sees the line
last exit direction -8~+8 06 where the line was before it was lost: −8 to +8 (negative = left); keeps the last value
line threshold 1~99 07 reflect threshold for 'on line', 1~99, default 50; set with E4
line calibration count 0~255 次 08 number of calibrations completed since power-on (button calibrations included)
channel [1~8] reflect 0~100 10~17 calibrated reflect of channel 18, 0100 (channel 1 = left); ids 10~17

More blocks (yes / no, events)

Block Related value
line is seen 04
on line [lost] 04
channel 1 is on the line 05
line follower is calibrating 08

Command blocks

Block Id Meaning
line follower follow [black] line E0 follow a black line (default); RAM only, back to the default after reset
line follower follow [white] line E1 follow a white line (F3 b1 = 1); RAM only, back to the default after reset
line follower calibrate [current reading is black] E2 store the current reading as black (sensor over the black line), ~50 ms; saved to EEPROM
line follower calibrate [current reading is white] E3 store the current reading as white (sensor over the white surface), ~50 ms; saved to EEPROM
line follower set threshold 50 E4 threshold 1~99 (RAM only, back to 50 after reboot); on SPIKE an out-of-range value returns failed (state 2)
line follower calibrate [auto (sweep for 5 s)] E7 sweep the sensor across black line and white surface for 5 s; min/max become the references; F3 b2 = 1 meanwhile

Status

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)

JavaScript

if (!(mbc.waitReady(0x16, 3000))) {
    basic.showIcon(IconNames.No)   // nothing answers: check wiring and power
}
basic.forever(function () {
    basic.showNumber(mbc.linePosition())   // line position
    basic.pause(100)
})

Sources and assumptions

Generated by _build/gen-reference.mjs from _build/protocol/line8.json (single source of truth, transcribed from the 2026-10-21 protocol decisions).

  • B-11:細位置 02 與線位置 01 同號(負 = 左);v1 韌體註解寫反,程式碼同號。
  • B-12:E7 五秒動態校準補回(v1 的 0x20=0x01),定案表沒列。
  • SPIKE 教育版模式 0 的 byte 8~15 補 0(#65 已改,使用者保留)。
  • EV3 模式 4 與模式 2 相同內容;模式 3 改壓線位元圖(#67)。
  • mBlock 舊版:MBC_MBLOCK_LEGACY=1 時逐 byte 同 2026-10-21 統一後韌體,0x0B 回 1。
  • The extension reads Int16LE and pauses 2 ms after writing the id (D5); with no sensor answering, reporters return 0 and yes / no blocks return false.
Email for a quoteBuying Guide