Students build a pocket pet in three milestones, using forever, events, a variable, ranges with else if, and a random pick from a list.
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, Run, Investigate 12 min · Milestone 1 10 min · Milestone 2 12 min · Milestone 3 12 min · Make it yours 9 min
This challenge uses every lesson in the course and adds nothing new. The pet is a variable, hunger, that forever makes go up (pause, then change by 1); A brings it down (with an if so it never goes below 0); if … else if … else turns the number into a face; and a shake picks a trick from a list at random. The milestones fade the help: Milestone 1 gives nearly all the code, Milestone 2 an outline, Milestone 3 only a goal. Build it yourself first; it takes about ten minutes.
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.
Four corners of the room: forever, A, face, shake. The teacher reads a job ("gets hungrier", "picks a trick", "eats"); students go to the corner that does it.
This is the plan for the milestones: each job has one home.
Leave your pet running and visit another table. Can you keep their pet happy for a minute?
Putting it all in the right blocks. Ask which block each job belongs in: time, button, face or shake.
| What you will see | A question to ask | The fix |
|---|---|---|
| hunger never changes. | Is the change block inside forever? | Drag change hunger by 1 inside forever, after the pause. |
| The pet is always sad, or always happy. | Read the questions from the top with hunger at 4. Which is true first? | Ask < 3 first, then < 6, then else. |
| hunger goes below 0. | What does A do when hunger is already 0? | Only change hunger by -1 if hunger > 0. |
One possible solution for each task. Other correct programs are fine.

let hunger = 0
input.onButtonPressed(Button.A, function () {
if (hunger > 0) {
hunger += -1
}
basic.showIcon(IconNames.Heart)
})
basic.forever(function () {
basic.pause(3000)
hunger += 1
basic.showNumber(hunger)
})

let hunger = 0
input.onButtonPressed(Button.A, function () {
if (hunger > 0) {
hunger += -1
}
basic.showIcon(IconNames.Heart)
})
basic.forever(function () {
basic.pause(3000)
hunger += 1
if (hunger < 3) {
basic.showIcon(IconNames.Happy)
} else if (hunger < 6) {
basic.showIcon(IconNames.Asleep)
} else {
basic.showIcon(IconNames.Sad)
}
})

let tricks = ["SPIN", "JUMP", "WAVE"]
let hunger = 0
input.onButtonPressed(Button.A, function () {
if (hunger > 0) {
hunger += -1
}
basic.showIcon(IconNames.Heart)
})
input.onGesture(Gesture.Shake, function () {
basic.showString(tricks[randint(0, tricks.length - 1)])
})
basic.forever(function () {
basic.pause(3000)
hunger += 1
if (hunger < 3) {
basic.showIcon(IconNames.Happy)
} else if (hunger < 6) {
basic.showIcon(IconNames.Asleep)
} else {
basic.showIcon(IconNames.Sad)
}
})
Open task: any program that does what the step asks.
Stretch: Add a second need, bored, with its own number, its own button and its own face rule. Which need wins when both are high?
Support: Pair students for Milestone 3: one reads the goal aloud while the other builds.
Your pet has: if hunger < 6 tired, else if hunger < 3 happy, else sad. What does it show when hunger is 1, and why?
Tired. 1 is less than 6, so the first question is true and the rest are skipped. Ask < 3 first.
Course complete. Next: micro:bit: talk and play, where functions name jobs and radio connects micro:bits. With real micro:bits: keep the pet in a pocket for a lesson and see if it survives.