Laser Ranger 2-ch × MATRIX Mini R4
The MATRIX edition of the Laser Ranger 2-ch plugs into a Mini R4 I2C port at address 0x22 and is read with the stock colour-sensor blocks: no library change, RK = seven 0255 numbers.
SPIKEEV3Arduino I2CmBlockMATRIXmicro:bit
Wiring
Use the stock MATRIX 4-pin sensor cable on I2C1 or I2C2 and pick that port in the block.
A. Stock blocks (0x22)
The "colour sensor → R / G / B / C / M / Y / K" blocks each return one 0~255 number. ⚠️ Do not use the stock H / S / V or colour-ID blocks (the host computes them from R, G, B; meaningless here); the grayscale and colour-number blocks were removed by MATRIX.
| Block | Content | Decode |
|---|---|---|
| R | left distance (cm) | |
| G | right distance (cm) | |
| B | nearer distance (cm) | B(命令 12 也回較近,schema 不收 12) |
// MATRIXblock → Arduino:stock library
int r = MiniR4.I2C1.MXColor.getColor(R); // left distance (cm)Sources and assumptions
Generated by _build/gen-reference.mjs from _build/protocol/tof2.json (single source of truth, transcribed from the 2026-10-21 protocol decisions).
- 共識 #8:08 左右平均 mm 補進 I2C/mBlock 值表(定案 §5 已列)。
- 0x22 命令 4
12 不動(4 左、5 右、6 最近、711 = 0、12 = 最近);schema 不收 11/12,所以 12 只寫在 03 的 note。 - EV3:模式 0、2、4 鎖住(照盤點);模式 1 改 [左,右]×4(index 0/1 各代表左右)、模式 3 改平均 mm、模式 5 改 [左 mm, 右 mm];模式 1 描述表宣告 int8 −100~100,cm×100/120 在範圍內。
- SPIKE:0/5/7/9 鎖住,另加模式 3 鎖住(網站 sensors/tof2/index.md read(3) = 左/右 cm,共識 #11);模式 6 改 [左 mm, 右 mm, 平均 mm];模式 1、2、4、8 維持不動;模式 8 v[0] 改 ID|hw[0]<<8(統一後共用函式)。
- 「左」= 站在車後往前看的左(第 0 顆,XSHUT PA6);韌體只有 L/R 巨集名,盤點檔標為推測。
- 沒有寫入命令;F8 換位址/EF 重開機用共用的。