Students use a variable that holds true or false to remember what is happening now, and fix a cheat in a reaction tester.
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 6 min · Investigate 12 min · Modify 8 min · Mix it up 3 min · Make 8 min · Class vote 3 min
A variable can hold true or false (Logic). It remembers one yes-or-no fact, such as is the heart showing? Each event either sets it (the heart appears: true) or asks about it with if. The usual bug is forgetting to set it back, so it keeps saying true and every later press counts. if waiting asks "is waiting true?"; there is no need to write = true.
On the slides at these points. Students can do the whole lesson on their own; these are for the room. In the deck, the Run, Modify and Make slides have the live playground in them (the tutorial link is the backup), and the notes above are in each slide's speaker notes.
One student holds a flag up only while the heart is 'showing' (the teacher holds up a heart card). Others clap: a clap counts only if the flag is up, and the first counted clap lowers it.
Forget to lower the flag and every clap counts: Raj's bug.
Swap with the next pair and try to cheat their reaction tester.
Knowing where to set it and where to ask. Ask: when does this fact become true, and when does it stop being true?
| What you will see | A question to ask | The fix |
|---|---|---|
| Every press shows a cross. | Where is waiting set to true? | Set waiting to true after the heart appears. |
| A second press still gives a time. | Where is waiting set back to false? | Set waiting to false inside the if, straight after the press is counted. |
| The if will not take waiting. | Is waiting a variable from Variables? | Drag the waiting variable straight into the if's hexagon slot. |
One possible solution for each task. Other correct programs are fine.

let on = false
input.onButtonPressed(Button.A, function () {
if (on) {
basic.clearScreen()
on = false
} else {
basic.showIcon(IconNames.Square)
on = true
}
})

let on = false
input.onButtonPressed(Button.A, function () {
if (on) {
basic.clearScreen()
on = false
} else {
basic.showIcon(IconNames.Square)
on = true
}
})
input.onGesture(Gesture.Shake, function () {
if (on) {
basic.showIcon(IconNames.Yes)
} else {
basic.showIcon(IconNames.No)
}
})

let waiting = false
let start = 0
input.onButtonPressed(Button.B, function () {
waiting = false
basic.clearScreen()
basic.pause(randint(1000, 4000))
basic.showIcon(IconNames.Heart)
start = input.runningTime()
waiting = true
})
input.onButtonPressed(Button.A, function () {
if (waiting) {
waiting = false
basic.showNumber(input.runningTime() - start)
} else {
basic.showIcon(IconNames.No)
}
})
Open task: any program that does what the step asks.
Stretch: Make the light switch remember how many times it was switched on, and show it on A+B.
Support: Give students the if … else in A already built, and ask them only to set waiting in the right places.
A program sets waiting to true when the heart appears, and never to false. What goes wrong?
Every press after the heart counts, not only the first, because waiting stays true.
Next: the final challenge. Build the reaction timer from scratch, then race a friend over radio.