Challenge 1
- When Center Button is pressed, play a sound "okey-dokey", then the motor turns clockwise. - When Center Button is released, stop motor and play a sound "bravo".
Quick Learn — the model, the instructions, the program and the challenges. The theory is in Full Lesson.
EV3 Robotics›Level 1 · Beginner›Lesson 2
Level 1 · Lesson 2 · EV3-L01-0260 minutes · Ages 7+ · Model: Wipers
The Wipers: a motor turns an arm through gears. The arm sweeps across and back, again and again. It is just like the wipers on a car’s windscreen.
It is a small, quick build. So why a whole lesson? A wiper is your first machine whose whole job is repetition. That means doing the same thing again and again. Not one sweep. The same sweep, for as long as it rains.
Today you meet your first loop, repeat. It runs blocks again and again. You also learn something that tricks almost everybody. A block can be in your program. It can be in the right order, with nothing wrong with it. And it can still never run!
Every car has wipers, and they work hard. Heavy rain can drop lots of water in ten minutes. Some countries get less in a month! In about two seconds, a driver cannot see through the windscreen at all.

A wiper arm does not spin round. It sweeps out and back in a curve, called an arc. That is because the glass has edges. Inside, a motor does spin all the way round. Some joined rods turn that spinning into a sweep. They are called a linkage.
The gears matter too. Look at your model. A small gear on the motor turns a big gear on the arm. That is called geared down. The arm moves slower, but it is stronger. A rubber blade on wet glass needs a big push.
Now think about the program. A wiper that sweeps once is no use. Rain does not stop after one wipe.
Now think of a wiper that sweeps a hundred times. But it clicks only once, at the very end. The click no longer matches the sweeps. Something for every sweep must happen every sweep. Not just once, when it is all over.
“Every time round” and “once at the end” are different. Only one thing tells them apart. It is where the block sits.
This is the Wipers you just built, on screen. The lesson’s program is already loaded. Press the green ▶ and watch it go.
Come back here as you work through the lesson. Predict first, then run. Load starter program puts the original back. When you hand in Basic or a Challenge, the program here goes with it.
Open the simulator full screen ↗
Got the real robot? In Chrome or Edge on a computer, press Connect at the top of the program and choose USB or Bluetooth. After the first time, the USB cable connects by itself when you plug it in. The Brick then runs the same program, and the robot on screen moves with the real one. Press Download (the arrow next to ▶) to save the program on the Brick. Then run it from the Brick’s File Navigation menu, with no computer.
A loop block is not a straight line. It is a C shape with a mouth. Blocks go either inside the mouth, or underneath the whole loop. Those two places work in different ways.
| Where the block sits | How often it runs |
|---|---|
| Inside the mouth of repeat (10) | Ten times — once per turn of the loop. |
| Underneath the loop, after its end | Once, after all ten turns have finished. |
| Underneath a forever loop | Never. Forever never finishes. The program never gets below it. |
That last row can waste a whole afternoon. The block is there. It is correct. But it will never run. The Brick will not tell you. There is no error, no warning, no red mark. The program is doing just what you built.
repeat (3)
forever
↑ this block never runs
Both programs contain the same green-light block. Let it run as long as you like — the right-hand ring will never turn green.
Both programs in that demo end with the same block. But only one ring ever lights up. It is not a mistake or a wrong number. It is just where the block sits. Inside the loop, or under it?
Before you blame a block, check. Is it inside the loop, or under it? A block under a forever loop never runs.
Machines repeat. A wiper sweeps, a conveyor runs, a ride goes round — and none of that should mean copying the same blocks over and over. A loop says “do this again” once.
| Block | What it does |
|---|---|
repeat (10) end | Runs the blocks inside a set number of times, then carries on below. |
forever end | Runs the blocks inside over and over, and never carries on below. |
repeat until <> end | Repeats until a condition becomes true — a loop with a sensor as its exit. |
Anything placed after a forever loop will never run. Not “runs late” — never. Both programs below end with the same block: set the status light green.
repeat (3)
forever
↑ this block never runs
Both programs contain the same green-light block. Let it run as long as you like — the right-hand ring will never turn green.
The repeat loop counts its three passes, stops, and moves on to the block underneath, so its light turns green. The forever loop reaches the bottom of its own blocks and jumps straight back to the top, so the block underneath is never reached — however long you leave it. If a program seems to stop half way through, look for a forever loop above the blocks that are not happening.
A program is a list, and the Brick works down it once. Every block runs, in order, and when the last one is done the program is over. That is fine for a list of instructions — drive, turn, beep, stop — because each is a thing you do once.
A sensor is not a thing you do once. Asking is 1 pressed? gives you an answer about this instant, and an instant later it may be wrong. Checking a sensor once tells you what the world was like at the moment the program started — which is almost never what you wanted to know.
So a program that has to react must ask again, and again, for as long as it is running. That is the whole job of the loop: not to repeat an action, but to keep the question being asked.
Wrap a sensor check and the motor it controls in a forever loop and you have built a closed-loop control system — the pattern behind every line follower, thermostat and cruise control:
It is called closed because the output feeds back round to the input: the motors move the robot, moving the robot changes what the sensor sees, and what the sensor sees changes the motors. Break the circle at any point and the robot stops responding.
when program starts :: events hat
forever
if <[1 v] is pressed? :: sensors> then
[A v] start motor [clockwise v] :: motors
else
[A v] stop motor :: motors
end
endRead it as a sentence and it is almost too simple to need explaining: for ever, if the button is pressed run the motor, otherwise stop it. The motor now follows the button for as long as the program is running.
This is the mistake nearly everybody makes first, and it is a hard one to spot because nothing about it looks wrong:
when program starts :: events hat if <[1 v] is pressed? :: sensors> then [A v] start motor [clockwise v] :: motors else [A v] stop motor :: motors end
The logic is perfect. The ports are right. Nothing is misspelled. And the robot will ignore the button completely — because the Brick reaches that if/else a few milliseconds after you press Run, finds the button not pressed, takes the else branch, stops the motor, runs out of blocks and ends. By the time a finger arrives, there is no program left to notice it.
with forever — a closed loop
without it — the common mistake
↑ running — for the only time
Both programs contain exactly the same if/else. The only difference is the forever block around one of them.
Both programs contain exactly the same if/else. The counter is what gives it away: one keeps checking for as long as it runs, the other is stuck on the single check it made before anybody touched anything. A student who has seen this once stops writing it.
The tell on a real robot is a program that ends the instant you start it — the Brick returns to its menu almost immediately. If a sensor program finishes rather than waits, the loop is what is missing.
The Brick has a small speaker. It can play one of the built-in sound files, or beep a note you choose. Sound is what makes a machine feel finished — and it is also a way for the robot to tell you something without you having to look at it.
| Block | What it does |
|---|---|
play sound [Communication / Hello v] until done :: sound | Plays the sound and waits for it to finish before the next block runs. |
start sound [Communication / Hello v] :: sound | Starts the sound and moves straight on to the next block, so the sound plays while the robot keeps working. |
play beep (60) for (0.5) seconds :: sound | Plays a single note for a set time — useful for short alerts. The number is a note, not a volume: bigger means higher. |
set volume to (100) % :: sound | Sets how loud everything after it will be. Worth putting at the top of a program — the Brick remembers the last volume it was given, even from somebody else’s program. |
stop all sounds :: sound | Cuts off anything that is still playing, including a long sound started earlier. |
These two blocks play the very same file. The difference is what the rest of the program does while it plays — so it cannot be heard on its own, only seen. Here are both, each lifting a barrier.
play sound until done
start sound
Watch the barriers, not the clock. On the left the warning finishes before anything moves; on the right it sounds while the barrier lifts.
The bars underneath are when the speaker was on and when the motor was turning. On the left they never overlap: the program is stuck at the sound block until the file has finished, and only then does the barrier lift. On the right they overlap almost completely, and the whole job is done in half the time.
Real machines warn before they move, not after: a lift chimes before the doors close, a reversing lorry beeps while it rolls back, a level crossing sounds before the barrier drops. Getting the order right is the difference between a warning and an apology.
Say this back: “Inside the mouth means every time round. Under the loop means afterwards. After a forever loop there is no afterwards.”
Two electronic parts, and two gears that help.
| Part | What it is doing here |
|---|---|
| EV3 Intelligent Brick | Runs the program. Its speaker also makes the click on each sweep. |
| Medium Motor | Moves the wiper arm. It is the flat one. It has a small red round part on the end. |
| The gear pair (no cable) | Geared down. The motor turns a lot, and the arm turns a little. This makes the arm strong enough. |
Turn the Brick off. How far does the arm sweep? You need to know before you can program it.
Sensors go in ports 1, 2, 3, 4. Motors go in ports A, B, C, D. You cannot swap them. If you do, nothing warns you. The robot just will not work.
| Part | Port | Why this one |
|---|---|---|
| Medium Motor (drives the wiper) | A | One motor on its own goes in A. Every program on this page says A. |
| The speaker | none | It is inside the Brick, like the screen and the light. |
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.
Today, a USB cable is really useful. This lesson uses a forever loop on purpose. A program that never ends is easiest to stop from the computer.
Today, most changes move a block, not a number. Predict before each run. How many times will you hear the sound? Say it out loud.
Remember step 5 for the rest of the course. Nothing is broken. Nothing is spelled wrong. There is just no after for that block to run in.
Does a block never seem to run? This is nearly always why. Check the loop first, before anything else. It is quicker than reading the block again and again.

When Center Button is pressed:
When Center Button is released:
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.
One page at a time — use Next and Previous, or the ← → keys. Fullscreen makes it big enough to build from.
The same build on Google Drive — sometimes a video, sometimes a scan:
Fullscreen it while you build — you can pause and scrub with the player's own controls.
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.
Work through them in order — each is harder than the last. The extra challenge comes after all three, and it is meant to make you plan before you build.
- When Center Button is pressed, play a sound "okey-dokey", then the motor turns clockwise. - When Center Button is released, stop motor and play a sound "bravo".
- When Up button is pressed, speed increases by 5, display the new speed. - When Down button is pressed, speed decreases by 5, display the new speed. - The motor speed must stay between 0% and 100% (it should not go above 100 or below 0). - Press the center button, the motor turns clockwise at the set speed, release it to stop the motor.
Set the initial speed to 0 1. When the center button is pressed, the motor will turn clockwise and increase the speed by 10 for every 1 second and update the motor speed on the display. 2. Stop the loop once speed exceeds 100%. 3. Play a countdown sequence ("Three", "Two", "One"), stop motor and exit the program.
Build the wiper a driver would really want. Show that nothing gets stuck. Your wiper must run for at least a minute with no break. It must sweep evenly. It must make a sound on each sweep. When you stop it, it must end neatly. The arm must park at one end. It must not stop halfway across the glass. A real wiper always parks at the end. Plan on paper before you build. A forever loop never ends, so nothing comes after it. If something must happen at the end, decide now how the program will get there. You will be asked two questions when you show it. Point at each block in your program. Say how many times it runs: once, once per sweep, or never. If a block never runs, why is it still in your program?