hermes-official-plugins
☤ The official plugins for Hermes Agent, built and maintained by Nous Research: Home Assistant, Spotify, Claude Subscription DirectSDK and more, one install away from the Hermes plugin catalog.
翻译准备中
MBC Pro Sensors (line follower, laser distance, gamepad, IMU, camera) for micro:bit V1/V2 MakeCode - beta: hardware bench test in progress
翻译准备中
正在加载完整 README。
查看完整 README ↗Open this page at https://contactmbcrobot.github.io/pxt-mbc-sensors/
MakeCode extension for MBC Pro Sensors on BBC micro:bit V1 and V2 (MBC I2C protocol v2, 2026-10). Product site: https://mbc-pro-sensors.github.io/ (繁體中文/English).
| Product | I2C address | Group | micro:bit page |
|---|---|---|---|
| Line follower 8-ch / 16-ch (循行者) | 0x16 | Line | line8 · line16 |
| Distance sensor 2-ch / 8-ch (測距者) | 0x29 | Distance | tof2 · tof8 |
| Gamepad receiver PS2 / PS4 (掌控者) | 0x42 | Gamepad | ps2 · ps4 |
| IMU / gyro (陀螺儀) | 0x6A | IMU | imu |
| ESP32 camera, school / WRO edition (神攝手) | 0x4C | Camera | esp32cam |
Wiring: MBC 4-pin cable to the micro:bit edge connector, P19 = SCL, P20 = SDA, 3V and GND. Several products can share the bus as long as their addresses differ (change an address with the Device blocks). Products that draw more than the micro:bit 3V pin can supply (distance 8-ch, ESP32 products) need their own power.
This repository can be added as an extension in MakeCode.
Traditional Chinese block names are included (_locales/zh-TW): switch the editor language to 繁體中文.
// Sweep the sensor over black and white for 5 s to calibrate (saved on the sensor)
mbc.lineCalibrate(MbcLineCalib.Auto)
basic.forever(function () {
// 0 = line in the centre, negative = line on the left (seen from behind the robot)
basic.showNumber(mbc.linePosition())
// channel 1 is the leftmost channel
if (mbc.lineChannelOnLine(1)) {
basic.showArrow(ArrowNames.West)
}
})
// Runs once when the robot loses the line
mbc.onLineEvent(MbcLineEvent.Lost, function () {
basic.showIcon(IconNames.No)
})
// Long-range mode: "no target" becomes 200 cm instead of 120 cm (sensor firmware 2026-10-29 or later)
mbc.tof8SetMode(MbcTofMode.LongRange)
basic.forever(function () {
// 2-way sensor: distance of the left laser in cm
basic.showNumber(mbc.tof2Distance(MbcTofSide.Left, MbcDistUnit.Cm))
// 8-way sensor: nearest target in mm and its direction (-8 left ... 0 front ... +8 right)
basic.showNumber(mbc.tof8Nearest(MbcDistUnit.Mm))
basic.showNumber(mbc.tof8NearestDirection())
})
// Runs when anything comes closer than 10 cm to the 8-way sensor
mbc.onTof8Near(10, function () {
basic.showIcon(IconNames.Skull)
})
// When ✕ is pressed: rumble and turn the light bar red (PS4 / PS5 gamepads)
mbc.onPadButton(MbcPadButton.Cross, MbcPadButtonEvent.Pressed, function () {
mbc.padRumble(200)
mbc.padLight(0xff0000)
})
basic.forever(function () {
// Only read the stick while a gamepad is paired; left stick up/down is -100 ... 100
if (mbc.padConnected()) {
basic.showNumber(mbc.padStick(MbcPadAxis.LeftY))
}
})
// Make the current direction 0°
mbc.imuZeroHeading()
basic.forever(function () {
// Heading in degrees, and nose up / down angle
basic.showNumber(mbc.imuHeading(MbcImuHeading.Fused))
basic.showNumber(mbc.imuPitch())
})
// Runs after the robot has turned 90°
mbc.onImuTurned(90, function () {
basic.showIcon(IconNames.Yes)
})
basic.forever(function () {
// School edition: X position of the tracked colour blob
if (mbc.camFound()) {
basic.showNumber(mbc.camBlob(MbcCamBlob.X))
}
// WRO edition: colour code of spot 1
basic.showNumber(mbc.camSpotColor(1))
})
// Wait up to 5 s for the line follower, then show its firmware version and kind
if (mbc.waitReady(mbc.ADDR_LINE, 5000)) {
basic.showString(mbc.firmwareVersion(mbc.ADDR_LINE))
basic.showNumber(mbc.deviceKind(mbc.ADDR_LINE))
}
If a sensor does not answer (unplugged, no power, wrong address), the blocks do not stop the program and print nothing:
0 (the firmware version returns an empty text);0 can also be a real reading (line in the centre, hue red, object touching the sensor), so check the connection first with device at … is ready (Device, advanced): it is false when nothing answers.
basic.forever(function () {
if (mbc.deviceReady(mbc.ADDR_LINE)) {
basic.showNumber(mbc.linePosition())
} else {
// nothing answers at 0x16: check the cable and power
basic.showIcon(IconNames.No)
}
})
以上为 README 的开头部分。其余内容请阅读原文。 查看完整 README ↗