Micro:Bit Week 2, Day 1

Add Extension in MakeCode

https://github.com/jhlucky/maqueen

Receiver

radio.onReceivedNumber(function (receivedNumber) {
    if (receivedNumber == 0) {
        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 () {
	
})

Sender

input.onGesture(Gesture.Shake, function () {
	
})
radio.setGroup(1)
basic.forever(function () {
    if (input.isGesture(Gesture.LogoDown)) {
        radio.sendNumber(0)
        basic.showArrow(ArrowNames.North)
    } else if (input.isGesture(Gesture.TiltRight)) {
        radio.sendNumber(1)
        basic.showArrow(ArrowNames.East)
    } else if (input.isGesture(Gesture.LogoUp)) {
        radio.sendNumber(2)
        basic.showArrow(ArrowNames.South)
    } else if (input.isGesture(Gesture.TiltLeft)) {
        radio.sendNumber(3)
        basic.showArrow(ArrowNames.West)
    } else {
        radio.sendNumber(4)
        basic.clearScreen()
    }
})