Two robots work together. One stands still as a tripwire and, when the other passes, cues it to do a trick.
Factories put sensors beside conveyor belts: when a box passes, the next machine is told to act. Shops use beams at the door to tell a speaker to chime. One device notices, another acts.
An optional challenge: two robots working as a team. One robot stands beside the track as a tripwire: its distance sensor watches the line. The other robot patrols. When the patrol robot passes in front of the tripwire, the tripwire sends a cue by radio, and the patrol robot does a trick.
Both robots run the same program. Press A+B on a micro:bit to make its robot the tripwire, then drag that robot beside the line, facing it. The simulator's distance sensor sees other robots as well as boxes.
Make your prediction first. Help opens once you've locked it in.

function followLine () {
if (robot.detectLine(RobotLineDetector.Left) && robot.detectLine(RobotLineDetector.Right)) {
robot.motorTank(40, 40)
} else if (robot.detectLine(RobotLineDetector.Left)) {
robot.motorTank(10, 40)
} else if (robot.detectLine(RobotLineDetector.Right)) {
robot.motorTank(40, 10)
} else {
robot.motorStop()
}
}
input.onButtonPressed(Button.AB, function () {
role = "tripwire"
robot.motorStop()
basic.showIcon(IconNames.Target)
})
let role = ""
robot.elecfreaksCuteBot.start()
radio.setGroup(1)
role = "robot"
basic.forever(function () {
if (role == "tripwire") {
if (robot.obstacleDistance() < 20) {
basic.showIcon(IconNames.Surprised)
} else {
basic.showIcon(IconNames.Target)
}
} else {
followLine()
}
})
Press A+B on the second micro:bit. Drag its robot next to the line, pointing at it, about a hand's width away in the simulator. Watch its micro:bit as the first robot goes past.

function followLine () {
if (robot.detectLine(RobotLineDetector.Left) && robot.detectLine(RobotLineDetector.Right)) {
robot.motorTank(40, 40)
} else if (robot.detectLine(RobotLineDetector.Left)) {
robot.motorTank(10, 40)
} else if (robot.detectLine(RobotLineDetector.Right)) {
robot.motorTank(40, 10)
} else {
robot.motorStop()
}
}
input.onButtonPressed(Button.AB, function () {
role = "tripwire"
robot.motorStop()
basic.showIcon(IconNames.Target)
})
let role = ""
robot.elecfreaksCuteBot.start()
radio.setGroup(1)
role = "robot"
basic.forever(function () {
if (role == "tripwire") {
if (robot.obstacleDistance() < 20) {
basic.showIcon(IconNames.Surprised)
} else {
basic.showIcon(IconNames.Target)
}
} else {
followLine()
}
})

function followLine () {
if (robot.detectLine(RobotLineDetector.Left) && robot.detectLine(RobotLineDetector.Right)) {
robot.motorTank(40, 40)
} else if (robot.detectLine(RobotLineDetector.Left)) {
robot.motorTank(10, 40)
} else if (robot.detectLine(RobotLineDetector.Right)) {
robot.motorTank(40, 10)
} else {
robot.motorStop()
}
}
input.onButtonPressed(Button.AB, function () {
role = "tripwire"
robot.motorStop()
basic.showIcon(IconNames.Target)
})
let role = ""
robot.elecfreaksCuteBot.start()
radio.setGroup(1)
role = "robot"
basic.forever(function () {
if (role == "tripwire") {
if (robot.obstacleDistance() < 20) {
basic.showIcon(IconNames.Surprised)
} else {
basic.showIcon(IconNames.Target)
}
} else {
followLine()
}
})
Ivy's tripwire, in forever:

basic.forever(function () {
if (role == "tripwire") {
if (robot.obstacleDistance() < 20) {
radio.sendString("trick")
}
}
})
Think about what forever is doing while the message arrives.
Turn the tripwire into a one-shot trigger:
Make a variable armed. On button A: if role = tripwire, set armed to true and show a tick.
In the tripwire's part of forever: if armed and distance < 20, set armed to false, send the word trick, and show a cross.
A arms the tripwire; when the robot passes, it sends 'trick' once and disarms.
This ticks by itself when your blocks do what is asked.
Make the patrol robot do a trick when it is cued: lights on, a quick wiggle, lights off, then back to patrolling. Keep the trick short and finish facing the same way, so the robot can find the line again.
Make a variable mode, set to patrol in on start. on radio received: if role = robot and the word is trick, set mode to trick.
In the robot's part of forever: if mode = trick, do the trick (lights and a wiggle), then set mode back to patrol; else follow the line.
When the patrol robot hears 'trick', it does a trick with its lights, then carries on patrolling.
This ticks by itself when your blocks do what is asked.
Make the team run by itself:
After the tripwire fires: count the pass (a variable passes, change by 1), show it, pause 5 seconds, then arm again.
Add a sound to the trick with play tone … in background, so the robot keeps moving.
The tripwire counts the passes, shows the count and re-arms itself; the trick plays a sound.
This ticks by itself when your blocks do what is asked.
With real robots, the tripwire can be a robot or just a micro:bit with an ultrasonic sensor. Place it a short distance from the track, facing across it. Real readings jump about, so you may need a range (for example between 5 and 20 cm) to ignore false readings near zero.
An optional challenge for students who finish early. Two robots work as a team; one stands still as a tripwire and, armed with a true/false variable, cues the patrolling robot once per pass; the patrol robot does a trick through its mode, then carries on. About 50 minutes.
Open the teacher guide: answers, solutions, slides and a worksheet.
Optional: the high ceiling of the course, not needed for Challenge complete. It is based on a common sensor pattern: one device notices, another acts. The tripwire is a robot that has been switched (A+B) to watch instead of drive; its distance sensor sees the other robot (the simulator treats robots as obstacles). Students drag the tripwire robot beside the line, facing it.
Two ideas from earlier come back: fire once (armed, like alerted in lesson 9) and handlers set the mode, forever does the job (lessons 6 and 11). The trick is a wiggle so the robot finishes facing along the line and can find it again; a full spin may leave it off the line.
Real ultrasonic sensors give false readings near zero, so a real tripwire often checks a range (for example 5 to 20 cm).
Firing once per pass with arm and disarm, and the trick in forever. Ask when the tripwire is armed and where the trick's moves are.
Stretch: Two tripwires at different places on the track, each sending a different word, and a different trick for each.
Support: Give Milestone 1 as a worked example to read; students build Milestones 2 and 3.
Real-world links: conveyor-belt sensors, shop door chimes, lap timers at races, automatic doors.