← Robotics challenges

Showcase

Build a robot dance show to a tune in three milestones, from a moves library to a finale with an emergency stop.

Robot shows at theme parks and festivals are built like this: a library of moves, a soundtrack in sections, a cue for each section, and a stop button for safety.

Time to put the course together in a show. A conductor micro:bit plays a tune phrase by phrase and sends a cue as each phrase starts (lesson 8). Dancer robots do a move for each cue, and each move is a function with its own lights (lesson 2). You will build it in three milestones, with less help each time.

In the simulator, press A+B on the first micro:bit to start the show; the second robot dances.

PredictRead the code and say what it will do before you run anything. A wrong guess is fine: it shows you what to look for.

Predict

The program as blocks
Show as code
show.ts
function wiggle () {
    robot.setColor(0xff00ff)
    robot.motorTank(50, -50, 300)
    robot.motorTank(-50, 50, 300)
    robot.motorStop()
}
function spin () {
    robot.setColor(0x00ffff)
    robot.motorTank(50, -50, 1200)
    robot.motorStop()
}
function phraseA () {
    radio.sendNumber(1)
    music.play(music.stringPlayable("C C G G A A G - ", 120), music.PlaybackMode.UntilDone)
}
function phraseB () {
    radio.sendNumber(2)
    music.play(music.stringPlayable("F F E E D D C - ", 120), music.PlaybackMode.UntilDone)
}
input.onButtonPressed(Button.AB, function () {
    phraseA()
    phraseB()
})
radio.onReceivedNumber(function (receivedNumber) {
    if (receivedNumber == 1) {
        wiggle()
        wiggle()
    } else if (receivedNumber == 2) {
        spin()
    }
})
robot.elecfreaksCuteBot.start()
radio.setGroup(1)
You press A+B on the first micro:bit. What does the second robot do?

RunRun it and compare the result with your prediction.

Run

Press A+B on the first micro:bit, with the sound on if you can.

The program as blocks
Show as code
show.ts
function wiggle () {
    robot.setColor(0xff00ff)
    robot.motorTank(50, -50, 300)
    robot.motorTank(-50, 50, 300)
    robot.motorStop()
}
function spin () {
    robot.setColor(0x00ffff)
    robot.motorTank(50, -50, 1200)
    robot.motorStop()
}
function phraseA () {
    radio.sendNumber(1)
    music.play(music.stringPlayable("C C G G A A G - ", 120), music.PlaybackMode.UntilDone)
}
function phraseB () {
    radio.sendNumber(2)
    music.play(music.stringPlayable("F F E E D D C - ", 120), music.PlaybackMode.UntilDone)
}
input.onButtonPressed(Button.AB, function () {
    phraseA()
    phraseB()
})
radio.onReceivedNumber(function (receivedNumber) {
    if (receivedNumber == 1) {
        wiggle()
        wiggle()
    } else if (receivedNumber == 2) {
        spin()
    }
})
robot.elecfreaksCuteBot.start()
radio.setGroup(1)
Try it yourselfYour edits are saved in this browser.
It opens full screen, so the robot simulator has room, and takes a few seconds to load. Esc comes back. Your work in this step is kept.

InvestigateTrace how each line of code connects to what you see.

Investigate

The program as blocks
Show as code
show.ts
function wiggle () {
    robot.setColor(0xff00ff)
    robot.motorTank(50, -50, 300)
    robot.motorTank(-50, 50, 300)
    robot.motorStop()
}
function spin () {
    robot.setColor(0x00ffff)
    robot.motorTank(50, -50, 1200)
    robot.motorStop()
}
function phraseA () {
    radio.sendNumber(1)
    music.play(music.stringPlayable("C C G G A A G - ", 120), music.PlaybackMode.UntilDone)
}
function phraseB () {
    radio.sendNumber(2)
    music.play(music.stringPlayable("F F E E D D C - ", 120), music.PlaybackMode.UntilDone)
}
input.onButtonPressed(Button.AB, function () {
    phraseA()
    phraseB()
})
radio.onReceivedNumber(function (receivedNumber) {
    if (receivedNumber == 1) {
        wiggle()
        wiggle()
    } else if (receivedNumber == 2) {
        spin()
    }
})
robot.elecfreaksCuteBot.start()
radio.setGroup(1)

Sort each part into its layer.

Think about where wiggle's blocks live.

Which layer of the show does each part belong to?

wiggle: turn right, turn left, stop, with pink lights
phraseB: send 2, then play F F E E D D C until done
if receivedNumber = 2, call spin
spin: turn for 1.2 seconds, stop, with blue lights

The director wants every wiggle in the show to be slower. Where is the one place to change?

ModifyChange the code on purpose and check the result.

Milestone 1: a moves library

The show so far has one move, wiggle, and one phrase. Add two more moves:

  1. spin: its own colour, turn for 1.2 seconds, then stop.
  2. shuffle: its own colour, forward a little, back a little, then stop.

Test each by calling it from wiggle's branch for a moment, then put wiggle back.

Try it yourselfYour edits are saved in this browser.
It opens full screen, so the robot simulator has room, and takes a few seconds to load. Esc comes back. Your work in this step is kept.
Need a hint?

In Advanced › Functions, make a function called spin, and another called shuffle.

Another hint

spin: set color, motor tank 50 −50 for 1200 ms, stop. shuffle: set color, forward for 300 ms, back for 300 ms, stop.

Add two moves to the library: spin and shuffle, each with its own lights and ending with a stop.

This ticks by itself when your blocks do what is asked.

ModifyChange the code on purpose and check the result.

Milestone 2: cue the show

Turn the moves into a show:

Twinkle's next phrases are F F E E D D C - and G G F F E E D -.

Try it yourselfYour edits are saved in this browser.
It opens full screen, so the robot simulator has room, and takes a few seconds to load. Esc comes back. Your work in this step is kept.
Need a hint?

phraseB sends 2 and plays F F E E D D C -. phraseC sends 3 and plays G G F F E E D -.

Another hint

Call the phrases in order on A+B. In on radio received, add else if branches for 2 (spin) and 3 (shuffle twice).

Three phrases, cues 1, 2 and 3, and a different move for each cue.

This ticks by itself when your blocks do what is asked.

MakeBuild something new using what you have learned. Expect a few tries; that is normal.

Milestone 3: finale and safety stop

Finish the show:

Then make it yours: change the tune, the moves or the colours.

Try it yourselfYour edits are saved in this browser.
It opens full screen, so the robot simulator has room, and takes a few seconds to load. Esc comes back. Your work in this step is kept.
Need a hint?

A fourth phrase sends 4. A finale function changes colour several times as it moves, then stops and shows a picture.

Another hint

The logo sends 0. In on radio received, an else at the end stops the robot and turns its lights off.

A finale on cue 4 with changing lights, and the logo sends a stop that every dancer obeys.

This ticks by itself when your blocks do what is asked.

Info

On a real robot

For a class show, one micro:bit (not in a robot) conducts and every robot in its radio group dances. Practise on the real floor: moves that look right in the simulator often need longer or shorter times. A dancer finishes the move it is doing before it obeys the stop, so keep moves short. Real shows have a person whose only job is the stop button.

For teachers

The performance challenge. Students build a robot show in three milestones (a moves library, three cued phrases, then a finale and a safety stop), combining functions, radio cues, music and decisions. About 60 minutes.

Open the teacher guide: answers, solutions, slides and a worksheet.

Students will be able to

Before class

This is the performance strand's challenge, using lesson 2 (moves as functions), lesson 7 (radio numbers become moves) and lesson 8 (phrases send cues, then play until done). A show has three layers that change independently: moves (functions with lights), cues (phrase functions on the conductor) and the dancer's choice of move for each cue (on radio received).

The milestones fade the help: Milestone 1 names the moves and gives their steps, Milestone 2 gives an outline, Milestone 3 gives goals only. Each starter is the previous milestone's solution, so a student who is stuck can still move on. Showcase and Patrol and alert together mark the course Challenge complete.

In the simulator, two micro:bits and two robots appear; the conductor's own robot does not dance. A dancer finishes its current move before it obeys the stop cue (radio events wait their turn), so short moves make the stop feel quicker. The logo needs a micro:bit V2 (it shows in the simulator); with V1 micro:bits, use shake for the stop.

Running the lesson

  1. Predict and Run: point out that each move sets its own lights first.
  2. Investigate: the three layers are the lesson's big idea. Write Move / Cue / Choice as three columns on the board.
  3. Milestone 1: two functions, each ending with a stop. Testing a new move by calling it from a branch is a real debugging habit.
  4. Milestone 2: phraseB and phraseC are copies of phraseA with new notes and cues.
  5. Milestone 3: let students design the finale. The check needs cue 4, a logo stop (cue 0) and at least five colour changes across the show.
  6. Real robot (optional): a whole-class performance with one conductor.

The hard part (on purpose)

Keeping moves, cues and choices as separate layers. When a move never happens, ask which cue calls it and whether that branch checks the right number.

When students get stuck

Stretch and support

Stretch: Two parts: give dancers a role variable (lead or chorus) so the same cue makes different robots do different moves.

Support: Pair students: one writes the moves library, the other the phrases, then they agree the cue numbers.

Where it leads

Real-world links: theme-park animatronics, drone light shows, stage lighting desks with cue lists. For a class performance, assign each group a section of a longer tune.

What each step is for

Now you can
Next lesson11. Patrol and alertBuild a patrol system in three milestones, a robot and a base that talk both ways, then add an alert log and status lights.