radio.onDataPacketReceived(function ({ receivedString }) {
if (receivedString == "A_Down") {
moveFront();
} else if (receivedString == "B_Down"){
moveBack();
} else if (receivedString == "AB_Down") {
rotateRight();
} else if (receivedString == "A_Up"
|| receivedString == "B_Up") {
stop();
}
})
radio.setGroup(1)
// デバッグ用
input.onButtonPressed(Button.A, function () {
moveFront();
})
input.onButtonPressed(Button.B, function () {
stop();
})
function moveFront() {
servos.P1.setAngle(0);
servos.P2.setAngle(180);
}
function moveBack() {
servos.P1.setAngle(180);
servos.P2.setAngle(0);
}
function rotateRight() {
servos.P1.setAngle(0);
servos.P2.setAngle(0);
}
function stop() {
servos.P1.setAngle(90);
servos.P2.setAngle(90);
}