1. Drive with gestures
Try firstThe model sends Left, then nothing. What does the robot do, and why?
Check your answer
It keeps turning left: the radio handler set the mode to Left, and forever keeps acting on the mode until a new label arrives.
The model sends a word; the robot remembers it as its mode.
- on radio received string sets the mode.
- forever acts on the mode, again and again, until a new word arrives.
- An else that stops is a safe default for words the robot doesn't know.

Show as code
radio.onReceivedString(function (receivedString) {
mode = receivedString
})
basic.forever(function () {
if (mode == "Forward") {
robot.motorTank(50, 50)
} else if (mode == "Left") {
robot.motorTank(-30, 30)
} else if (mode == "Right") {
robot.motorTank(30, -30)
} else {
robot.motorStop()
}
})
// Test remote: the buttons send what the model would send.
input.onButtonPressed(Button.A, function () {
radio.sendString("Left")
})
input.onButtonPressed(Button.B, function () {
radio.sendString("Right")
})
input.onButtonPressed(Button.AB, function () {
radio.sendString("Forward")
})
input.onLogoEvent(TouchButtonEvent.Pressed, function () {
radio.sendString("Stop")
})
let mode = ""
robot.elecfreaksCuteBot.start()
radio.setGroup(7)



