RVR and Micro:Bit

IMG_0872 IMG_0872

Micro:Bit sets the lights of the RVR based on Temperature or Button A is pressed.

1 Like

Hello, how did you do it? Is it convenient to share the code? Thank you very much

1 Like

My email is: quanxin.du@revoit-asia.com

1 Like

Code is below for the first micro:bit. It communicates with 2 other micro:bits.

This link has info on adding extension for micro:bit to communicate with RVR.
https://edu.sphero.com/cwists/preview/39837x

basic.showIcon(IconNames.Heart)

let direction = “0”

input.onButtonPressed(Button.A, () => {

if (direction == “0”) {

basic.showArrow(2)

basic.pause(1000)

} else {

basic.showArrow(6)

basic.pause(1000)

}

basic.clearScreen()

radio.sendString(“A”)

})

radio.onDataPacketReceived(({ receivedString }) => {

if (receivedString == “0” || receivedString == “1”) {

direction = receivedString

// basic.showString(direction)

} else {

if (receivedString == “B” && direction == “1”) {

basic.showArrow(6)

sphero.drive(30, 0)

basic.pause(600)

sphero.stop(0)

basic.clearScreen()

direction = “0”

radio.sendString(direction)

basic.pause(1400)

basic.showArrow(2)

sphero.drive(-30, 0)

basic.pause(600)

sphero.stop(0)

radio.sendString(“A”)

basic.pause(600)

basic.clearScreen()

}

}

})

input.onButtonPressed(Button.B, () => {

if (direction == “0”) {

basic.showString(“R”)

direction = “1”

} else {

basic.showString(“L”)

direction = “0”

}

radio.sendString(direction)

basic.pause(1000)

basic.clearScreen()

})

1 Like