Micro:Bit Week 2, Day 2

radio.onReceivedNumber(function (receivedNumber) {
    if (receivedNumber == 0) {
        if (maqueen.sensor(PingUnit.Centimeters) < 30) {
            if (Math.randomBoolean()) {
                maqueen.MotorRun(maqueen.aMotors.M1, maqueen.Dir.CW, 127)
maqueen.MotorRun(maqueen.aMotors.M2, maqueen.Dir.CCW, 127)
            } else {
                maqueen.MotorRun(maqueen.aMotors.M1, maqueen.Dir.CCW, 127)
maqueen.MotorRun(maqueen.aMotors.M2, maqueen.Dir.CW, 127)
            }
            basic.pause(500)
        } else {
            maqueen.MotorRun(maqueen.aMotors.M1, maqueen.Dir.CW, 255)
maqueen.MotorRun(maqueen.aMotors.M2, maqueen.Dir.CW, 255)
        }
        basic.showArrow(ArrowNames.North)
    } else if (receivedNumber == 1) {
        maqueen.MotorRun(maqueen.aMotors.M1, maqueen.Dir.CW, 127)
maqueen.MotorRun(maqueen.aMotors.M2, maqueen.Dir.CCW, 127)
basic.showArrow(ArrowNames.East)
    } else if (receivedNumber == 3) {
        maqueen.MotorRun(maqueen.aMotors.M1, maqueen.Dir.CCW, 127)
maqueen.MotorRun(maqueen.aMotors.M2, maqueen.Dir.CW, 127)
basic.showArrow(ArrowNames.West)
    } else if (receivedNumber == 2) {
        maqueen.MotorRun(maqueen.aMotors.M1, maqueen.Dir.CCW, 255)
maqueen.MotorRun(maqueen.aMotors.M2, maqueen.Dir.CCW, 255)
basic.showArrow(ArrowNames.South)
    } else if (receivedNumber == 4) {
        maqueen.motorStopAll()
        basic.clearScreen()
    }
})
radio.setGroup(1)
basic.forever(function () {
    
})