Students make a model-driven robot safe when the model is unsure (the board sends Unsure) and when it goes quiet (a watchdog stops the robot after a few seconds of silence).
Load these into Waypoints Prepare: choose Load URL and paste the copied address, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.
Predict and Run 8 min · With your model 10 min (typical) · Investigate 8 min · Modify 8 min · Make 10 min
The idea: a robot driven by a model needs a safe action for two different problems:
lastHeard = running time) and stops the robot when too long has passed.For the watchdog to work, a robot that is working fine must keep hearing from the board, so the board repeats the current label every second (a heartbeat). Without the repeat, holding Forward steadily would trip the watchdog.
Without robots: in the simulator, A+B sends Forward once and B sends Unsure; the model step is typical.
Deciding what the robot does when the model isn't sure, and the watchdog timing. Ask what should happen when nothing has been heard for a while, before they build it.
| What you will see | A question to ask | The fix |
|---|---|---|
| The robot stops every two seconds even while the gesture is held. | Is the board repeating the label (repeat: 1)? Is the robot's radio group right? | Use this lesson's board; check the group. |
| The robot never stops after silence. | Is lastHeard set in on radio received string? Is the check in forever? | Set lastHeard on every message and compare in forever. |
| The robot beeps over and over. | Does it beep only when the mode first becomes Lost? | Beep only if the mode wasn't Lost already. |
One possible solution for each task. Other correct programs are fine.

radio.onReceivedString(function (receivedString) {
mode = receivedString
lastHeard = input.runningTime()
})
basic.forever(function () {
if (input.runningTime() - lastHeard > 1000) {
mode = "Stop"
}
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()
}
})
input.onButtonPressed(Button.AB, function () {
radio.sendString("Forward")
})
input.onButtonPressed(Button.B, function () {
radio.sendString("Unsure")
})
let lastHeard = 0
let mode = ""
robot.elecfreaksCuteBot.start()
radio.setGroup(7)

radio.onReceivedString(function (receivedString) {
mode = receivedString
lastHeard = input.runningTime()
})
basic.forever(function () {
if (input.runningTime() - lastHeard > 2000) {
mode = "Stop"
}
if (mode == "Forward") {
robot.motorTank(50, 50)
} else if (mode == "Left") {
robot.motorTank(-30, 30)
} else if (mode == "Right") {
robot.motorTank(30, -30)
} else if (mode == "Unsure") {
robot.motorStop()
robot.setColor(0xffff00)
} else {
robot.motorStop()
}
})
input.onButtonPressed(Button.AB, function () {
radio.sendString("Forward")
})
input.onButtonPressed(Button.B, function () {
radio.sendString("Unsure")
})
let lastHeard = 0
let mode = ""
robot.elecfreaksCuteBot.start()
radio.setGroup(7)

radio.onReceivedString(function (receivedString) {
mode = receivedString
lastHeard = input.runningTime()
})
basic.forever(function () {
if (input.runningTime() - lastHeard > 1500) {
if (mode != "Lost") {
robot.playTone(262, 300)
}
mode = "Lost"
}
if (mode == "Forward") {
robot.motorTank(50, 50)
} else if (mode == "Left") {
robot.motorTank(-30, 30)
} else if (mode == "Right") {
robot.motorTank(30, -30)
} else if (mode == "Lost") {
robot.motorStop()
robot.setColor(0xff0000)
} else {
robot.motorStop()
}
})
input.onButtonPressed(Button.AB, function () {
radio.sendString("Forward")
})
let lastHeard = 0
let mode = ""
robot.elecfreaksCuteBot.start()
radio.setGroup(7)
Stretch: Slow down instead of stopping when Unsure arrives once, and stop only after three Unsures in a row.
Support: Give the watchdog's if complete; students add only the actions inside it.
Why does a robot need both an Unsure action and a watchdog?
Unsure handles a model that can't decide; the watchdog handles getting no messages at all. Both make the robot stop.
Next: some mistakes cost more than others. Real world: dead man's switches on trains, heartbeat checks in drones and delivery robots.