Challenge 1
Make both buttons work. One raises the car while held, the other lowers it while held, and both stop the instant they are released. Then park the car at three different heights your teacher points to, without overshooting any of them.
EV3 Robotics›Level 2 · Intermediate›Lesson 35
Level 2 · Lesson 35 · EV3-L02-3560 minutes · Ages 9–16 · Model: Lift Simulation 2
The Lift: a tower with a car on a string, a Large Motor to wind it, and two Touch Sensors — one to send it up and one to bring it down.
There is a problem built into this machine, and it is worth seeing before you write anything. Nothing tells the robot where the top is. There is no sensor up there. If the motor keeps winding after the car reaches the roof, the string snaps or the tower comes apart.
Every model so far solved this by counting — so many rotations, so many degrees. Today you solve it a completely different way: the machine runs only while somebody is holding the button down, and the person watching becomes the part that knows when to stop.
Every tall building in KL has lifts, and every one of them has a panel of buttons. You press a floor and let go, and the lift takes itself there.

A passenger lift can work like that because it knows where it is. There are sensors at every floor and switches at the very top and bottom of the shaft, so the lift can take a single press and be trusted to stop in the right place.
Now look at a construction hoist on a building site — or a drill press, or the platform lift on a lorry. Those often have a different kind of control: a button or lever that works only while it is held. Let go and the machine stops instantly.
Engineers call it a hold-to-run control, and they use it wherever the machine cannot be trusted to judge for itself.
Your lift has no floor sensors and no limit switch. Give it a press-once-and-go button and the very first mistake is a broken model: the car reaches the top, the motor keeps winding, and something gives.
If a machine cannot tell when to stop, do not build it a button that lets it run unwatched.
A trigger and a hold-to-run control use the same sensor and look almost the same in a program. They are completely different machines.
| Pattern | What it means for the person |
|---|---|
Trigger — Lessons 13, 22, 23[1 v] wait until [bumped v] :: sensors | Click and let go. The machine now does its thing whether you are watching or not. |
Hold-to-run — today[1 v] wait until [pressed v] :: sensors [1 v] wait until [released v] :: sensors | It moves while your finger is down and stops the instant you lift it. You are part of the machine. |
The whole pattern is four blocks, and the order is the idea: wait for the press, start the motor, wait for the release, stop it. Notice that the motor block in the middle is start motor — the one with no ending built in, from Lesson 4 — because the ending is going to come from the person, not from a number.
That is the deep point. Every other model in this course has had its ending written into the program. This one has its ending held in somebody’s hand.
Bumped means “go and keep going”. Pressed-then-released means “go for exactly as long as I say”.
The Touch Sensor is the simplest input the EV3 has: a button that is either pressed or not. That sounds trivial, but it is how a robot knows it has hit a wall, reached the end of a track, or been told to start by a person.
| Block | What it does |
|---|---|
wait until <[1 v] is pressed? :: sensors> | Holds the program here until somebody presses the sensor. |
<[1 v] is pressed? :: sensors> | Reports true or false. Drop it into a condition to make a decision rather than a wait. |
[1 v] when [bumped v] :: events hat | Starts a whole stack of its own. The dropdown chooses the moment: pressed, released or bumped. |
A button is not only “pressed”. One press is three things: the moment it goes down, the time it stays down, and the moment it comes back up. Watch what a single press does to three programs at once.
versus two hat blocks
The middle counter is the one that surprises people. Nothing is wrong with it — a loop really does check that fast, and every check really is a separate answer.
Nothing there is broken. A loop really does get round hundreds of times a second, and each time it asks is pressed? the honest answer is still yes — so if that loop plays a sound or counts something, it does it hundreds of times from one finger. The two hat blocks each fire once, and they fire at different moments: pressed the instant the button goes down, bumped only when it comes back up.
The three options, and what each is for:
when program starts :: events hat set movement motors to [B v] and [C v] :: movement start moving [straight: 0] :: movement wait until <[1 v] is pressed? :: sensors> stop moving :: movement
The robot drives until something presses the sensor. Note that the movement is started unmeasured on purpose — the sensor decides when to stop, not a distance.
Touch sensors are everywhere in machines you cannot see into: a lift knows the doors are shut, a printer knows the lid is closed, a washing machine will not spin until it is latched. They are safety devices as much as inputs.
The Large Motor is the bigger of the two EV3 motors. It turns more slowly than the Medium Motor but pushes far harder, which is why it drives wheels and lifts loads. If a mechanism struggles or stalls with a Medium Motor, this is usually the answer.
| Block | What it does |
|---|---|
[B v] run [clockwise v] for (3) [rotations v] :: motors | Turns the motor a measured amount, then stops. |
[B v] run [clockwise v] for (2) [seconds v] :: motors | Turns it for a length of time rather than a distance, then stops — however far the shaft actually got. |
[B v] set speed to (40) % :: motors | Sets how fast the next movement will be. |
[B v] start motor [clockwise v] :: motors | Starts it turning and carries straight on. |
Give both motors the same program and the same arm. With nothing on the arm the Medium Motor wins easily — which is why it is tempting to treat it as simply the better motor. Then the demo hangs a weight on both arms and runs it again.
and on the Large Motor, only the port changes
Turning the speed up would not rescue the Medium Motor here — a stalled motor needs more force, which means gearing it down or using the Large Motor.
That is the whole difference. The Medium Motor is quicker; the Large Motor is stronger. A motor that cannot produce enough force does not move slowly — it stops altogether and strains, which is the buzzing, going-nowhere failure almost every LEGO builder meets sooner or later.
Being stronger buys the Large Motor a bigger load, not an infinite one. Every winch runs out of cable and every lift reaches the top of its rails, and when a motor arrives at a limit it stalls: the shaft stops turning and the motor sits there straining.
That is a problem for the program, not just the mechanism. run for (3) rotations does not finish when three rotations’ worth of time has gone by — it finishes when the shaft has actually turned three times. A winch that reaches the top after two and a half will never report three, so the block waits, and every block after it is unreachable. Nothing crashes. The motor keeps pushing and the rest of the program simply never happens.
The third setting in that dropdown is the way out. for () seconds drives the motor for a duration and then stops regardless, so it always finishes and the program always moves on. Drive into a limit slowly, for a comfortably long time, and then call that position zero:
when program starts :: events hat [B v] set speed to (30) % :: motors [B v] run [counterclockwise v] for (3) [seconds v] :: motors [B v] reset degrees counted :: motors
The lift ends up against its own stop, the encoder is zeroed there, and every measured move afterwards starts from a place you know. The rule is the same for both motors: if the movement ends against something solid, run for seconds; if it ends somewhere in the middle, measure it. The Medium Motor module has the animation for it — see The Medium Motor, which is where this bites hardest, because a Medium Motor is usually the one doing the lifting.
The blocks are identical apart from the port letter, so swapping one motor for the other is a build change, not a programming change.
Real machines match the motor to the load. A lift uses a powerful, slow motor; the button panel beside it uses tiny ones. Choosing the wrong size is the most common reason a LEGO mechanism whines but does not move.
Say this back before moving on: “It runs while the button is down and stops when I let go.”
| Part | What it is doing here |
|---|---|
| EV3 Intelligent Brick | Runs the program and forms the base of the tower. |
| Large Motor | Winds the string. Port A. Strong, because it is lifting against gravity the whole way up. |
| Touch Sensor ×2 | Up and down. Identical parts told apart only by port — the Lesson 22 rule, and it applies again. |
| The string (no cable) | Holds the whole car. It can pull and it cannot push, so gravity does the lowering. |
Brick off. You are finding the limits that the machine has no way of knowing.
Nothing in the program knows about either limit. You found them, you remember them, and today your finger is what respects them.
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 |
|---|---|---|
| Large Motor (winds the string) | A | A single motor with a job of its own takes A. |
| Touch Sensor — UP | 1 | Touch is always port 1 in this course. |
| Touch Sensor — DOWN | 2 | The second one borrows the Gyro’s slot, as on lessons 22 and 23. No Gyro here to mind. |
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.
Keep every cable clear of the string and the car. A cable that catches the car mid-lift will stop it, and the motor will keep winding — which is exactly the failure this lesson exists to prevent.
Seven blocks, and the whole hold-to-run pattern is the four inside the loop. This program only does up — down is yours to add in the next section.
when program starts :: events hat [A v] set speed to (30) % :: motors forever [1 v] wait until [pressed v] :: sensors [A v] start motor [clockwise v] :: motors [1 v] wait until [released v] :: sensors [A v] stop motor :: motors end
Walk it in the order the Brick runs it:
What success looks like: the car goes up smoothly while you hold, stops immediately when you let go, and stays where it is. Try stopping it exactly halfway. Then exactly two-thirds of the way. You can put it anywhere, which no measured program has let you do all course.
Do not test what happens at the top. Let go well before the car reaches the pulley. You already know what would happen, and knowing is enough.
One change at a time, and predict before each run. Always keep a finger ready to let go.
Step 4 is the comparison the whole lesson is for. Both programs use the same sensor and the same motor. One stops when the person says so; the other stops when a number says so — and only one of those two knows where the top of the tower is.
When the machine cannot know, keep the person in the loop. That is a design decision, not a shortcut.
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.
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 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.
Make both buttons work. One raises the car while held, the other lowers it while held, and both stop the instant they are released. Then park the car at three different heights your teacher points to, without overshooting any of them.
Add a display that helps the operator: the screen must show whether the lift is going UP, going DOWN or STOPPED, changing at the moment the movement does. Someone across the room should be able to tell what the lift is doing without seeing your hands.
Show why hold-to-run was the right choice. Build a second version that uses bumped to start and a measured number of rotations instead, then demonstrate both to somebody who has not seen the model and ask which they would trust near the top. Report what they said and whether you agree.
Build a hoist a site foreman would sign off. Your lift must be operated safely by somebody who has never seen it: clearly labelled controls, a display that says what is happening, and no way to reach the top of the tower by accident. Hand it to another group and let them use it without instruction. Plan on paper before you build. List every way the car could be driven into the top of the tower, and decide what stops each one — remembering that your machine has no sensor up there and cannot be given one today. Two questions when you demonstrate it. What is the safety system on this machine, in one sentence? And what would you add first if you were allowed one more sensor?