Challenge 1
Cycle through three named modes and act on each one, with the screen always showing the current mode.
EV3 Robotics›Level 2 · Intermediate›Lesson 18
Level 2 · Lesson 18 · EV3-L02-1860 minutes · Ages 9–16 · Model: Battle Rescue Robot
The Battle Rescue Robot: a driving base with a magazine that holds up to ten short beams, and a Medium Motor that releases a rubber band to launch them one at a time.
It is meant to be sent somewhere a person should not go — to clear a path, to knock something over, to reach and come back. One machine, several different jobs.
By the end of the lesson your robot will have a menu — three modes, cycled with one button and confirmed with another, with the live mode always visible on the screen.
Safety, before anything else. This model launches a beam. Point it at a wall or a cardboard box, never at a person, an animal or a window. Everybody within two metres wears eye protection. One rule, no exceptions, all lesson.
Bomb disposal robots are sent in so that a person does not have to be there. One machine carries a camera, an arm, a gripper and sometimes a disruptor, and an operator a safe distance away chooses which to use.

One robot with several tools beats several robots with one tool each. It is cheaper, it is one thing to carry and maintain, and — the real reason — you do not know which tool the job needs until you get there.
But it creates a problem that a single-purpose machine never has. The same control now does different things depending on what mode the robot is in. The operator has to know which mode they are in before they touch anything.
You already know this failure. Type your password with Caps Lock on: every key does something different from what you intended, nothing warns you, and you only find out afterwards. The keyboard was in a mode and did not say so.
In aviation this has a name — mode confusion — and it has caused real crashes: a crew believing the autopilot was in one mode while it was in another, both giving perfectly correct commands to a system doing something else. The fix, everywhere, is the same: show the mode, all the time, where the operator is looking.
A mode you cannot see is a trap. If a machine has modes, its display has one job above all others.
Lesson 34’s Transmitting Gyro had a variable with two values, 0 and 1, and one button flipped between them. Nothing said it had to stop at two.
change [mod v] by (1) if <(mod) > (3)> then set [mod v] to (1) end write (mod) at line (1) :: display
if is what makes it a cycle instead of a number that runs away.Without those three lines the counter goes 4, 5, 6, and every mode check after 3 fails. The robot ends up in no mode at all, silently — and change by 1 gives no warning, because counting past 3 is a perfectly reasonable thing for a number to do.
Check for greater-than, not equals. if <(mod) > (3)> catches 4 and also catches 7 if anything ever skipped. if <(mod) = (4)> works right up until something increments twice, and then the menu is broken for the rest of the session. Lesson 33 made the same point about the ammunition counter.
The mode is picked with one button and acted on with another, and that separation is the whole design:
if <(mod) = (1)> then
move [forward v] for (2) [rotations v] at (40) % speed :: movement
else
if <(mod) = (2)> then
[A v] run [clockwise v] for (1) [rotations v] at (100) % speed :: motors
else
move [backward v] for (3) [rotations v] at (60) % speed :: movement
end
endNotice there is no fourth branch and no need for one. The final else catches everything that is not 1 or 2, and because the wrap keeps mod in range, that means 3.
Long before there were computers, people had exactly this problem. A shepherd counting sheep through a gate, a trader counting sacks of grain, a builder counting days — none of them can hold the number in their head while they get on with the work. So they scratched a mark on a wall, cut a notch in a stick, or wrote a number on a piece of paper. The number lived outside the person, in a place they had agreed on, and they could go back to it, read it, and change it.
Better still, once the number is written down somebody else can use it. Watch these two: one of them counts and writes, the other never sees a single animal and simply reads the wall.
Notice what never happens: Ben never asks Abby. He does not need to — the number is not in her head, it is on the wall, and the wall is there for anyone who needs it.
Neither Abby nor Ben is holding the number — the wall is. And notice what never happens: Ben does not ask Abby. He does not need to, because the count is not in her head. It is in a place they both agreed on, which is what makes it useful to more than one of them.
That is all a variable is. The robot cannot hold a number in its head either, so you give it a wall of its own, write a name at the top so everyone knows which wall is which — score, count, degree_turn — and the program can read what is on it and write something new. One part of the program writes; another part reads. Exactly Abby and Ben.
Say we are counting rotations of a motor. Before we start we write 0 on the paper. Every time the motor completes a turn we cross out what is there and write one more: 0 becomes 1, then 2, then 3. That is change — it has to read the old number to work out the new one.
set is the other thing you can do, and it is completely different: rub the whole paper out and write the number you want. It does not care what was there. Press the buttons and watch what happens to the crossings-out.
The paper starts blank, so we write 0 on it. That is what a variable is: a place to keep a number while the robot works.
| Block | What it does |
|---|---|
set [count v] to (0) | Puts a value in, replacing whatever was there. |
change [count v] by (1) | Adds to what is already there. |
(count) | Reports the current value, for use in a comparison or on the display. |
set replaces; change adds. Counting things needs change. Starting a count needs set. Both programs below have both blocks — the only difference is whether the set block is inside the loop or above it.
set before the loop
set inside it
Both programs contain both blocks. Only the position of set [count] to 0 is different.
The count on the right is not broken; it is being told to start again on every pass. Each time round the loop it is wiped back to zero and then changed by one, so the honest answer is always 1 — while the motor cheerfully turns four times. A counter stuck at 1 almost always means a set block that has slipped inside the loop.
EV3 Classroom tells you what a block does by its shape, and once you have noticed that, a whole set of questions answers itself:
So when a slot is oval, any oval fits it — and it does not matter in the least where that number came from. You can take the motor’s own A degrees counted and keep it in a variable you named degree_turn, then compare that with a number later. Pick an oval below and watch the same one drop into all three kinds of slot.
pick an oval
the same oval fits all three
Every one of those slots is oval-shaped, and A degrees counted is an oval — so it drops in. Nothing about where the number came from matters.
This is what makes a variable more than a counter. A sensor reading is true only at the instant you read it; copying it into a variable freezes it, so the robot can compare where it is now against where it was when something happened:
when program starts :: events hat [A v] reset degrees counted :: motors set [degree_turn v] to ([A v] degrees counted :: sensors) start moving [right: 30] :: movement wait until <(([A v] degrees counted :: sensors) - (degree_turn)) > (400)> stop moving :: movement
Read the condition aloud: how far the motor has gone now, minus where it was when we started, is more than 400. Both are ovals, so both can go into a subtraction, and the subtraction is an oval too — which is why it can go into a comparison. Ovals nest inside ovals as deep as you need.
A variable keeps its value after the program ends. Run the program again without setting it back and the second run begins where the first left off — the count starts at 14, the robot thinks it has already done the job. Every variable a program changes must be set to its starting value at the top.
A variable is the difference between a machine that repeats a fixed routine and one that responds to how things have gone — counting parts, tracking a score, remembering where it started.
The Brick has five buttons of its own — up, down, left, right and centre. They need no sensor, no cable and no port, which makes them the easiest way to let a person tell the robot to do something.
| Block | What it does |
|---|---|
when [center v] button [pressed v] :: events hat | Starts a whole stack when that button is pressed. |
wait until <is [center v] button pressed? :: sensors> | Holds an existing program until the button is pressed. |
A program sitting on a wait block looks exactly like a program that has crashed. Watch one wait — including through two presses of the wrong button.
the other way to do it
A program parked on a wait block looks identical to a crashed one. This is why the status light or a line on the screen is worth setting before you wait.
The wait is watching one button. Up and right change the (button) reading, and the program does not care. That reading is a number rather than a name: 0 for nothing, then 1 left, 2 centre, 3 right, 4 up, 5 down.
Nearly every machine has a start button that is deliberately separate from switching the power on. A robot that begins moving the instant it is powered up is hard to set down and hard to test — one that waits for a press can be positioned first.
A mode is a variable with more than two values. Wrap it, and show it.
Long before there were computers, people had exactly this problem. A shepherd counting sheep through a gate, a trader counting sacks of grain, a builder counting days — none of them can hold the number in their head while they get on with the work. So they scratched a mark on a wall, cut a notch in a stick, or wrote a number on a piece of paper. The number lived outside the person, in a place they had agreed on, and they could go back to it, read it, and change it.
Better still, once the number is written down somebody else can use it. Watch these two: one of them counts and writes, the other never sees a single animal and simply reads the wall.
Notice what never happens: Ben never asks Abby. He does not need to — the number is not in her head, it is on the wall, and the wall is there for anyone who needs it.
Neither Abby nor Ben is holding the number — the wall is. And notice what never happens: Ben does not ask Abby. He does not need to, because the count is not in her head. It is in a place they both agreed on, which is what makes it useful to more than one of them.
That is all a variable is. The robot cannot hold a number in its head either, so you give it a wall of its own, write a name at the top so everyone knows which wall is which — score, count, degree_turn — and the program can read what is on it and write something new. One part of the program writes; another part reads. Exactly Abby and Ben.
Say we are counting rotations of a motor. Before we start we write 0 on the paper. Every time the motor completes a turn we cross out what is there and write one more: 0 becomes 1, then 2, then 3. That is change — it has to read the old number to work out the new one.
set is the other thing you can do, and it is completely different: rub the whole paper out and write the number you want. It does not care what was there. Press the buttons and watch what happens to the crossings-out.
The paper starts blank, so we write 0 on it. That is what a variable is: a place to keep a number while the robot works.
| Block | What it does |
|---|---|
set [count v] to (0) | Puts a value in, replacing whatever was there. |
change [count v] by (1) | Adds to what is already there. |
(count) | Reports the current value, for use in a comparison or on the display. |
set replaces; change adds. Counting things needs change. Starting a count needs set. Both programs below have both blocks — the only difference is whether the set block is inside the loop or above it.
set before the loop
set inside it
Both programs contain both blocks. Only the position of set [count] to 0 is different.
The count on the right is not broken; it is being told to start again on every pass. Each time round the loop it is wiped back to zero and then changed by one, so the honest answer is always 1 — while the motor cheerfully turns four times. A counter stuck at 1 almost always means a set block that has slipped inside the loop.
EV3 Classroom tells you what a block does by its shape, and once you have noticed that, a whole set of questions answers itself:
So when a slot is oval, any oval fits it — and it does not matter in the least where that number came from. You can take the motor’s own A degrees counted and keep it in a variable you named degree_turn, then compare that with a number later. Pick an oval below and watch the same one drop into all three kinds of slot.
pick an oval
the same oval fits all three
Every one of those slots is oval-shaped, and A degrees counted is an oval — so it drops in. Nothing about where the number came from matters.
This is what makes a variable more than a counter. A sensor reading is true only at the instant you read it; copying it into a variable freezes it, so the robot can compare where it is now against where it was when something happened:
when program starts :: events hat [A v] reset degrees counted :: motors set [degree_turn v] to ([A v] degrees counted :: sensors) start moving [right: 30] :: movement wait until <(([A v] degrees counted :: sensors) - (degree_turn)) > (400)> stop moving :: movement
Read the condition aloud: how far the motor has gone now, minus where it was when we started, is more than 400. Both are ovals, so both can go into a subtraction, and the subtraction is an oval too — which is why it can go into a comparison. Ovals nest inside ovals as deep as you need.
A variable keeps its value after the program ends. Run the program again without setting it back and the second run begins where the first left off — the count starts at 14, the robot thinks it has already done the job. Every variable a program changes must be set to its starting value at the top.
A variable is the difference between a machine that repeats a fixed routine and one that responds to how things have gone — counting parts, tracking a score, remembering where it started.
Say this back before moving on: “Cycle, wrap, show — then act.”
Look at your robot. Three motors and no sensors — so where does everything the robot knows come from? (From you. That is what the menu is for.)
| Part | What it is doing here |
|---|---|
| EV3 Intelligent Brick | The robot and the control panel. Its screen is the most important part today — it is the only thing telling the operator which mode they are in. |
| Large Motor ×2 — the drive | A matched pair, taking the robot in and bringing it back. |
| Medium Motor — the launcher | Releases the band. One shot per rotation, so its own port and its own mode. |
| The magazine and band (not electronic) | Holds up to ten beams and stores the energy. Nothing here counts them — which is Lesson 33’s counter waiting to be added. |
Step 3 matters more than it looks. The starting mode is the one somebody gets by accident. Make it the one that cannot hurt anybody.
Sensors go in ports 1, 2, 3, 4. Motors go in ports A, B, C, D. They are not interchangeable, and nothing will tell you politely if you swap them.
| Part | Port | Why this one |
|---|---|---|
| Left drive wheel | B | The pair. Two motors, one job. |
| Right drive wheel | C | The other half of the pair. |
| Launcher | A | Its own job, away from the pair. |
| Sensors | none | A person chooses the mode and a person decides when to act. Adding a sensor that chooses the mode is what the challenges are for. |
The manual never says which port anything goes in — it ends at the last building step with no cables drawn. So the ports above are this course’s conventions, not the manual’s instructions, and nothing in your build contradicts them.
Check your own build now:
Two routes, and either is fine. USB is the reliable one and the one to fall back on when a room’s Bluetooth is busy; Bluetooth leaves the robot free to move, which some models need.
Do these in order. Naming the Brick after you go looking for it in the list is how groups end up driving each other’s robots.
EV3 until somebody changes it.EV3.The two failures, every class, every time. The Brick has gone to sleep while you were building — press the centre button to wake it. Or you have paired with the group at the next table, which is why the name matters.
The long version, including Port View and how to read the port tiles, is in the Brick & Bluetooth guide.
Bluetooth, and hold the Brick where you can read it. The whole lesson rests on the operator being able to see the mode. If the screen is face-down on a desk while the robot drives away, you have built exactly the trap step 2 described.
Stuck? The long version, with a photograph of every screen, is in the Brick & Bluetooth guide.
Three stacks: set up, cycle the menu, and act on whatever is selected.
when program starts :: events hat
set movement motors to [B v] and [C v] :: movement
set [mod v] to (1)
clear display :: display
write [1 MARA ] at line (1) :: display
when [left v] button [pressed v] :: events hat
change [mod v] by (1)
if <(mod) > (3)> then
set [mod v] to (1)
end
if <(mod) = (1)> then
write [1 MARA ] at line (1) :: display
else
if <(mod) = (2)> then
write [2 LANCAR ] at line (1) :: display
else
write [3 UNDUR ] at line (1) :: display
end
end
when [center v] button [pressed v] :: events hat
if <(mod) = (1)> then
move [forward v] for (2) [rotations v] at (40) % speed :: movement
else
if <(mod) = (2)> then
[A v] run [clockwise v] for (1) [rotations v] at (100) % speed :: motors
else
move [backward v] for (3) [rotations v] at (60) % speed :: movement
end
endWhat success looks like: the screen reads 1 MARA. Press left twice and it reads 3 UNDUR. Press left once more and it wraps to 1 MARA. Press centre and the robot does exactly what the screen says — every time, with no surprises.
If the screen and the action disagree, your two Switch chains have drifted apart. That is the mode-confusion bug in miniature, and it is worth sitting with for a moment: the robot is behaving perfectly and lying about it.
One change at a time, and hand the Brick to somebody else after each without explaining. Whether they can use it is the only test that counts.
mod is 6 and no branch matches, except the final else, which now fires the wrong thing. Find out which.if <(mod) = (4)>. It works. Now press left very fast and see whether you can make it skip past 4. This is why greater-than is safer.peluru is 0, and show it on line 2.Step 3 and step 6 are the same lesson from opposite ends. Take the display away and a working robot becomes unusable; add a second, wordless display and it becomes usable from further away. None of that changed what the robot does. All of it changed whether a person can work with it.
Every path that changes the mode must also change the display. No exceptions, or the screen becomes a liar.

Build the model before you read any further. Everything after this is about making it do something, and none of it will make much sense with nothing on the table in front of you.
Use the viewer's own controls to zoom and turn pages. Fullscreen makes it big enough to build from.
The same build on Google Drive — sometimes a video, sometimes a scan:
Use the viewer's own controls to zoom and turn pages. Fullscreen makes it big enough to build from.
Check the finished build against the picture before you switch anything on. A motor mounted the wrong way round is far easier to spot now than it is to debug later, when it looks like a program fault.
This model drives, so its challenges are run on a mat. Mats differ between branches — check you are looking at the one in your room.

WRO 2026 RoboMission Elementary — Robot Rockstars · official WRO game mat, 2362 × 1143 mm
The challenges name these places rather than distances, so the same challenge works on any mat:
Work through the challenges in order — each is harder than the last. The mission comes after all three, and it is meant to make you plan before you build.
Cycle through three named modes and act on each one, with the screen always showing the current mode.
Add a fourth mode, and make sure the wrap still works when the button is pressed very fast.
Show the mode on the status light as well as the screen, so it can be read from across the room without reading words.
Design a rescue mission with three stages the robot must be switched between at the right moments — advance, clear an obstacle, withdraw with something recovered. Then hand the Brick to somebody who has never seen your program and see whether they can complete the mission from the screen alone.