← AI robots

A wrist remote

A model can run on the remote itself. A wrist micro:bit running a CreateAI model turns its own movements into the same words the webcam sent, so the robot's program doesn't change and no computer or camera is needed.

Some controllers for drones and assistive devices are worn on the wrist or hand: tilt to steer, hold still to stop. The model lives in the controller, so there is no camera to point and no laptop to carry.

Last lesson, a model on the computer watched your hand through the webcam, and the bridge sent its labels to the robot. In AI on the micro:bit (micro:bit and the computer) you trained a model on movements that runs on the micro:bit itself. Put that micro:bit on your wrist and it can be the remote: each action it recognises becomes a radio command.

In the simulator, one program holds both parts and the ML panel chooses the action. The practice actions stand in for the ones you will train: walking for push forward, waving for tilt left, clapping for tilt right, still for stop.

WidthMore contexts, same idea.
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
wrist.ts
// Wrist: each action the model recognises becomes a command
ml.onStart(ml.event.Walking, function () {
    radio.sendString("Forward")
})
ml.onStart(ml.event.Waving, function () {
    radio.sendString("Left")
})
ml.onStart(ml.event.Clapping, function () {
    radio.sendString("Right")
})
ml.onStart(ml.event.Still, function () {
    radio.sendString("Stop")
})
// Robot: the same code as Drive with gestures
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()
    }
})
let mode = ""
robot.elecfreaksCuteBot.start()
radio.setGroup(7)
You swap the webcam model for this wrist remote. What has to change in the robot's part of the program?

RunRun it and compare the result with your prediction.

Run

Open the editor full screen. In the ML panel, choose walking, then waving, clapping and still, and watch the other robot.

The program as blocks
Show as code
wrist.ts
// Wrist: each action the model recognises becomes a command
ml.onStart(ml.event.Walking, function () {
    radio.sendString("Forward")
})
ml.onStart(ml.event.Waving, function () {
    radio.sendString("Left")
})
ml.onStart(ml.event.Clapping, function () {
    radio.sendString("Right")
})
ml.onStart(ml.event.Still, function () {
    radio.sendString("Stop")
})
// Robot: the same code as Drive with gestures
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()
    }
})
let mode = ""
robot.elecfreaksCuteBot.start()
radio.setGroup(7)
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.

Run TypicalRun it and compare the result with your prediction.

On your wrist

  1. In CreateAI, train four actions with the micro:bit on your wrist: forward (tip your hand forward), left, right (tip it sideways) and still.
  2. Click Edit in MakeCode and add radio send string to each on ML … start, with the same words as the robot uses, and radio set group to match. Download it to the V2 on your wrist.
  3. Download the robot part (from the Run step) to the robot's micro:bit.

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

Investigate

The program as blocks
Show as code
wrist.ts
// Wrist: each action the model recognises becomes a command
ml.onStart(ml.event.Walking, function () {
    radio.sendString("Forward")
})
ml.onStart(ml.event.Waving, function () {
    radio.sendString("Left")
})
ml.onStart(ml.event.Clapping, function () {
    radio.sendString("Right")
})
ml.onStart(ml.event.Still, function () {
    radio.sendString("Stop")
})
// Robot: the same code as Drive with gestures
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()
    }
})
let mode = ""
robot.elecfreaksCuteBot.start()
radio.setGroup(7)
The wrist model isn't sure of any action (unknown). What does this program send?

You hold your hand tipped forward for ten seconds. How many times does the wrist send Forward?

Webcam model on the computer, or wrist model on the micro:bit: which suits each?

Reading printed signs held up to the robot's route
Steering with no laptop nearby, outside
Recognising what an object looks like
Nothing about you is seen or sent anywhere

ModifyChange the code on purpose and check the result.

Modify

Need a hint?

Add on ML start, choose unknown, and send Stop.

Need a hint?

In each on ML start, after sending: show arrow (north, west, east), and a square for still.

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.

When the wrist model is unsure (unknown), send Stop.

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

The wrist shows an arrow for each command it sends, and a square for Stop.

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.

Make

Make a full wrist remote: Forward, Left, Right, a Spin (jumping, or a flick you train) and Stop, with unknown sending Stop and the wrist showing each command. Add Spin to the robot's part.

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?

Wrist: one on ML start per action, each sending a word and showing what it sent; jumping sends Spin; unknown sends Stop.

Another hint

Robot: in forever, one branch per word, with Spin as motor tank 60 −60, and else stop.

A full wrist remote: Forward, Left, Right, Spin (jumping) and Stop, unknown sends Stop, the wrist shows each command, and the robot drives each one.

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

For teachers

Students drive the robot from a wrist micro:bit running a CreateAI movement model, so the model runs on the remote and the robot's program is unchanged. About 45 minutes.

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

Students will be able to

Before class

The idea: the robot only ever receives words (Forward, Left, Right, Stop). Any model that sends those words can drive it. Here the model runs on a wrist micro:bit (trained in CreateAI, needing a V2): on ML … start sends a word by radio. No computer, camera or bridge is needed once both micro:bits are programmed.

In the simulator: the lesson's editor has the robot blocks and the Machine Learning blocks with practice actions; one program holds both parts and the ML panel picks the action (walking for forward, waving for left, clapping for right, still for stop). Open it full screen so the panel and the robots show. This has not yet been tried in the live editor: check before class.

With hardware: students reuse their CreateAI skills from micro:bit and the computer: train four tilt actions with the micro:bit on the wrist (a strap or band and a battery pack), Edit in MakeCode, add radio send string and set group, and download to the V2. Every pair needs its own radio group.

Running the lesson

  1. Predict: some say the robot needs the ML blocks. Ask: what does the robot receive?
  2. Run: choose actions in the ML panel and watch the other robot.
  3. Investigate: unknown sending nothing is the safety gap; holding a tilt sends once, which sets up the watchdog lesson.
  4. Make: Spin needs a branch on both sides: the remote's word and the robot's move.

The hard part (on purpose)

Two programs on two micro:bits that must agree on the radio group and the words. Ask them to read both sides aloud before changing either.

When students get stuck

Stretch and support

Stretch: Use certainty (%) for forward to set the speed: a small tilt drives slowly, a big tilt drives fast.

Support: Give the robot part complete (it is unchanged); students write only the wrist part.

Where it leads

Next: what the robot should do when the model is unsure or goes quiet. Real world: wearable controllers for drones and assistive devices.

What each step is for

Now you can
Next lesson3. When the model is unsureA robot driven by a model needs a safe action for when the model is unsure and for when it goes quiet. The board sends Unsure and repeats its label; the robot stops on Unsure, and a watchdog stops it when nothing arrives.