MicroBit Robo:Bit MK3

https://4tronix.co.uk/blog/?p=1832

Programming Robobit Buggy in Makecode

https://4tronix.co.uk/blog/?p=1872

Makecode Editor

https://makecode.microbit.org/#editor

My Code

input.onButtonPressed(Button.A, function () {
    // Turn Motors ON
    stopGO = 1
})
input.onButtonPressed(Button.B, function () {
    // Turn Motors OFF
    stopGO = 0
})
let TurnNow = 0
let stopGO = 0
// On Start, Turn robot OFF
stopGO = 0
// Our model KIT
robobit.select_model(RBModel.Mk3)
basic.forever(function () {
    if (stopGO) {
        if (TurnNow > 80) {
            robobit.rotatems(RBRobotDirection.Left, 60, 400)
            TurnNow += 1
        }
        robobit.stopScanner()
        if (robobit.sonar(RBPingUnit.Centimeters) < 20) {
            basic.showLeds(`
                . . # . .
                . . # . .
                . . # . .
                . . . . .
                . . # . .
                `)
            robobit.setLedColor(0xFF0000)
            robobit.driveMilliseconds(-544, 500)
            robobit.rotatems(RBRobotDirection.Left, 60, 400)
        } else {
            basic.showLeds(`
                # # . # #
                . . . . .
                . . # . .
                # . . . #
                . # # # .
                `)
            robobit.setLedColor(0x18E600)
            robobit.go(RBDirection.Forward, 50)
            basic.pause(500)
        }
    } else {
        robobit.setPixelColor(0, 0xFFFFFF)
        robobit.setPixelColor(7, 0xFFFFFF)
        robobit.startScanner(0x0000FF, 100)
    }
})

image alt text