PyoBot is a micro:bit robot car board extension for Microsoft MakeCode. Control motors, line sensors, ultrasonic sensor, LEDs, buzzer, and servo with simple blocks.
- Open https://makecode.microbit.org
- Create or open a project
- Click Extensions
- Paste this URL:
https://github.com/pyocodingcompany-crypto/pyobot-makecode
For purchase, bulk orders, or classroom use inquiries:
- Email: pyocodingcompany@gmail.com
- KakaoTalk: Request open-chat link via email
This extension requires a PyoBot robot car board connected to a BBC micro:bit. Motor, line sensor, ultrasonic and LED blocks automatically disable the micro:bit LED matrix due to shared pin usage (P3, P4, P6, P7, P9, P10).
Run motors forward or backward at a given speed (0–1023).
// Run both motors forward at speed 500
pyobot.motorRun(PyoMotor.Both, PyoDirection.Forward, 500)
// Run left motor backward at speed 300
pyobot.motorRun(PyoMotor.Left, PyoDirection.Backward, 300)
// Stop all motors
pyobot.motorStop(PyoMotor.Both)
Turn by stopping one side and driving the other.
// Turn left at speed 500
pyobot.motorTurn(PyoTurn.Left, 500)
// Turn right at speed 500
pyobot.motorTurn(PyoTurn.Right, 500)
Read line sensor values. Returns 0 for white surface, 1 for black line.
// Read raw value
let val = pyobot.lineSensor(PyoLineSensor.Left)
// Boolean: is black line detected?
if (pyobot.lineDetected(PyoLineSensor.Left)) {
pyobot.motorRun(PyoMotor.Left, PyoDirection.Forward, 1023)
}
// Boolean: is black line NOT detected?
if (pyobot.lineNotDetected(PyoLineSensor.Right)) {
pyobot.motorStop(PyoMotor.Right)
}
Line tracing example:
basic.forever(function () {
if (pyobot.lineDetected(PyoLineSensor.Left)) {
pyobot.motorRun(PyoMotor.Left, PyoDirection.Forward, 1023)
} else {
pyobot.motorStop(PyoMotor.Left)
}
if (pyobot.lineDetected(PyoLineSensor.Right)) {
pyobot.motorRun(PyoMotor.Right, PyoDirection.Forward, 1023)
} else {
pyobot.motorStop(PyoMotor.Right)
}
})
Measure distance in centimeters using the ultrasonic sensor (P1 trig, P10 echo).
// Show distance on LED matrix
let dist = pyobot.ultrasonic()
basic.showNumber(dist)
Obstacle avoidance example:
basic.forever(function () {
if (pyobot.ultrasonic() < 15) {
pyobot.motorStop(PyoMotor.Both)
pyobot.motorTurn(PyoTurn.Right, 500)
basic.pause(500)
} else {
pyobot.motorRun(PyoMotor.Both, PyoDirection.Forward, 500)
}
})
Control left (P3) and right (P4) LEDs on the board.
// Turn on both LEDs
pyobot.pyoLed(PyoLED.Both, PyoLEDState.On)
// Turn off left LED
pyobot.pyoLed(PyoLED.Left, PyoLEDState.Off)
Play tones on the buzzer (P0). Frequency in Hz, duration in ms.
// Play middle C for 500ms
pyobot.buzzer(262, 500)
// Stop buzzer
pyobot.buzzerOff()
Control a servo motor on P2. Angle range: 0–180 degrees.
// Set servo to 90 degrees
pyobot.servo(90)
// Release servo (stop PWM signal)
pyobot.servoRelease()
| Function | Pin |
|---|---|
| LED Left / Right | P3 / P4 |
| Buzzer | P0 |
| Line Sensor Left / Right | P6 / P7 |
| Ultrasonic Trig / Echo | P1 / P10 |
| Motor Left (PWM, Dir) | P8, P9, P13 |
| Motor Right (PWM, Dir) | P16, P14, P15 |
| Servo | P2 |
| I2C (SCL / SDA) | P19 / P20 |
Note: Motor, line sensor, ultrasonic and LED blocks disable the micro:bit LED matrix because P3, P4, P6, P7, P9, P10 are shared with the LED display. Use an I2C OLED display if you need a screen alongside these blocks.
PyoBot works alongside HuskyLens over I2C (P19/P20). No pin conflict.
See test.ts for a complete test suite. Press buttons A, B, or A+B on the micro:bit to run different test groups.
MIT
- for PXT/microbit