Challenge 1
Pick something up. Carry it across the table. Put it down again. Do not drop it. Do not squeeze it too hard. Choose the thing yourself. Be ready to say why you chose it. Something hard and something soft will not need the same grip.
Quick Learn — the model, the instructions, the program and the challenges. The theory is in Full Lesson.
EV3 Robotics›Level 1 · Beginner›Lesson 39
Level 1 · Lesson 39 · EV3-L01-3960 minutes · Ages 7+ · Model: Mechanical Clamp
The Mechanical Clamp: a gripper you hold in your hand. A motor moves the jaws. Two Touch Sensors sit right where your fingers rest. Your thumb presses one to grab. A finger presses the other to let go.
This model is a tool. Most machines so far, you switched on and watched. This one, you pick up and use, like the Fencing sword.
By the end of the lesson, it will work in your hand. You will also find something your blocks cannot do yet.
People use motor grippers to hold things they cannot touch. A robot deep under the sea picks things up from the sea floor. In some science labs, grippers work behind thick glass, because the things inside are dangerous. A doctor’s robot closes tiny jaws inside a patient. It goes in through a hole as thin as a pencil.

Grab and let go have separate buttons, on purpose. One button for both would be smaller and cheaper. But it would be much more dangerous. The person would have to remember which way it would go next.
With two buttons, there is nothing to remember. The one under your thumb always closes. The one under your finger always opens. Even if you are tired or not paying attention, you will not drop what you are holding.
Real grippers also know when to stop. Some feel how hard they are squeezing. Some have a switch that clicks when the jaws are fully open. Without that, what if a shut gripper is told to shut harder? It keeps pulling until something breaks. That could be the motor, the gears, or the thing it holds.
Remember that. Your clamp is about to have this same problem. And you are going to solve it.
A tool in your hand must always do what you expect, even when you are not thinking about it.
This model has no step-by-step guide. We have a video of the finished clamp, not steps to follow. You will work out the build from it, with your teacher.
Watch it twice. The first time, watch the jaws. The second time, watch where the two sensors are next to the hand. If the buttons are in the wrong place, your hand hurts after a minute. You get to choose where they go.
You can tell your clamp to close, and to open. But nothing in it remembers which one it did last.
Today you meet a new kind of start block. It is called an event hat. Like when program starts, it sits on top of a stack. But it waits for a sensor. Each hat starts its own stack. Now think of the Machine Gun in Lesson 38. Two sensors that look the same are told apart by only the port. Put those together, and the clamp is easy. One hat for port 1 closes. One hat for port 2 opens.
It works. Then someone presses grab twice.
Press grab when the clamp is already shut. The motor tries to close the jaws, but they cannot go any further. So the motor gets stuck. You saw this on the Push-up Robot in Lesson 32. It keeps straining until the block ends, or something breaks.
| What a good gripper would do | What we can do today |
|---|---|
| Remember whether it is open or shut | Nothing. To remember, you need a variable. You do not have one yet. |
| Check before moving — if it is already shut, do not close | Nothing. To check, you need a Switch. You meet it in Lesson 43. |
| Stop when the jaws cannot go any further | Build it in. Choose a movement so small it cannot break anything. Then the person holding it is the memory. |
The third row is the answer you can use today. It is a real engineer’s answer, too. If you cannot make the program safe, make the machine safe. You have done this before. In Lesson 9, you fixed the EV3 Fan in the build, not the program.
If a machine cannot remember, build it so that forgetting does no harm.
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.
Everything an EV3 does begins with a motor turning. Before worrying about how far or how fast, there are only two things to say to a motor: start and stop. The blocks are the same whichever motor you use — only the port letter changes.
| Block | What it does |
|---|---|
[A v] start motor [clockwise v] :: motors | Starts the motor and immediately carries on to the next block. The motor keeps turning on its own. |
[A v] stop motor :: motors | Stops the motor. |
wait (2) seconds | Holds the program here, which is how you control how long a motor runs. |
Because start motor does not wait, a motor started on its own would run until the program ended. The pattern that gives a motor a length is three blocks:
when program starts :: events hat [A v] start motor [clockwise v] :: motors wait (2) seconds [A v] stop motor :: motors
Read it aloud: start it, leave it two seconds, stop it. Change the wait and you change how far the motor gets.
The highlight below follows the block the Brick is running, and the shaft turns only while the program is between start motor and stop motor. Notice that the count keeps climbing all the way through the wait — the wait does not pause the motor, it pauses the program.
0.00rotations so farnoshaft turning
The count does not pause when the program does. A wait holds up the blocks, and the motor carries on turning underneath it.
This is the whole idea behind start motor: it hands the motor its instruction and moves on, leaving the motor running behind it. Nothing stops the shaft until a block tells it to.
The direction dropdown says clockwise or counterclockwise — but clockwise seen from where? Always from the axle end: look straight at the shaft coming towards you, and clockwise is the way a clock’s hands go.
Here the Medium Motor faces you, so its output axle points straight out of the page. This is the view to picture when you are choosing a direction.
when program starts :: events hat [A v] start motor [clockwise v] :: motors wait (2) seconds [A v] stop motor :: motors
A Medium Motor normally lives in port A or D.
The Large Motor is shown from the side, which is the face its axle comes out of — so once again you are looking straight down the shaft.
when program starts :: events hat [B v] start motor [clockwise v] :: motors wait (2) seconds [B v] stop motor :: motors
A Large Motor normally lives in port B or C. Compare the two programs: they are the same three blocks, and only A has become B.
A fan, a conveyor belt or a spinning ride does not need to stop at an exact position — it just needs to run while something is happening. For those, timing the motor is simpler and perfectly good enough.
Waiting is how a program gives the physical world time to catch up. There are two kinds, and choosing between them is one of the first real design decisions in robotics.
| Block | What it does |
|---|---|
wait (1) seconds | Holds the program for a fixed length of time, whatever else is happening. |
wait until <> | Holds the program until a condition becomes true — usually a sensor reading. |
Most sensors bring their own ready-made wait block, already coloured to match the sensor and with its comparison built in. They are all the same idea — hold here until this is true — and they live in the sensor’s own palette rather than in Control.
| Sensor | Block | Waits until |
|---|---|---|
| Touch | [1 v] wait until [pressed v] :: sensors | the button is pressed. The dropdown also offers released and bumped. |
| Colour | [3 v] wait until color is [red v] :: sensors | the surface underneath is that one of the eight colours. |
| Ultrasonic | [4 v] wait until distance [< v] (15) [cm v] :: sensors | something is nearer than 15 cm. Flip the dropdown to > to wait for something to move away. |
| Gyro | [2 v] wait until angle [< v] (45) :: sensors | the robot has turned past that angle. |
| Brick buttons | wait until [center v] button is [pressed v] :: sensors | somebody presses that button on the Brick. No port — it is built in. |
Some readings have no wait block of their own — reflected light, ambient light, the timer, and a motor’s degrees counted. For those, drop the matching boolean into the plain wait until from Control. It does exactly the same job:
wait until <[3 v] is reflected light intensity [< v] (30) %? :: sensors> wait until <[3 v] is ambient light intensity [> v] (50) %? :: sensors> wait until <(timer) > (5)> wait until <([A v] degrees counted :: sensors) > (720)>
This is also the way to wait for two things at once, which no ready-made block can do — the sensor blocks each take one condition, but a boolean can be combined:
wait until <<[1 v] is pressed? :: sensors> or <(timer) > (5)>>
That one says “stop waiting when the button is pressed, or after five seconds, whichever comes first” — which is how you stop a wait hanging for ever when the thing you are waiting for never happens.
Two robots, the same job: drive up to the wall and stop. One waits two seconds; the other waits for the wall. Let it run several times — the interesting part is what happens on the second and third run.
wait for a length of time
wait for a condition
Each orange dash is where a previous timed run finished. The sensing robot has never left a second mark, because it has never stopped anywhere else.
The timed robot is not being careless. Two seconds is a perfectly good guess, and on the first run it may look exactly right. But a second covers a different distance on a fresh battery, on a dusty floor, or with a heavier load, so the robot finishes somewhere new every run — sometimes short, sometimes into the wall. The sensing robot has never had to guess.
Prefer waiting for a condition wherever a sensor can tell you. Keep timed waits for things with no sensor to check — letting a sound finish, or pausing so a person can watch.
A lift that waits three seconds for its doors is guessing; one that waits for the door sensor knows. The first eventually closes on somebody.
Say this out loud before you move on: “My clamp does not know if it is open or shut. I am its memory.”
Look at your clamp. Three things have cables. Two of them look exactly the same.
Which motor is it? This model has no guide, so no page can tell you. Hold yours next to these two pictures and decide.
| Part | What it is doing here |
|---|---|
| EV3 Intelligent Brick | Runs the program, and is the handle. It is heavy, so your hand gets tired. Think about that when you choose where to hold it. |
| One motor, port A | Opens and closes the jaws. Whichever motor you have, the program says A. It works the same. |
| Touch Sensor, port 1 | Under the thumb. Grab. |
| Touch Sensor, port 2 | Under a finger. Release. |
Move the jaws by hand, all the way each way. Find where they are fully shut, and where they are fully open. Section 9 needs you to know how far the jaws can move before they stop.
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.
The course’s usual table is Touch=1, Gyro=2, Colour=3, Ultrasonic=4. This model has two Touch Sensors. So the second one borrows the Gyro’s port, and goes in port 2. That is fine, because there is no Gyro here. Lesson 38, the Machine Gun, did the same. We say it out loud, so nobody is surprised.
| Part | Port | Why this one |
|---|---|---|
| Touch Sensor — grab | 1 | The usual Touch port. Your thumb presses this one. |
| Touch Sensor — release | 2 | Borrowed from the Gyro. The two sensors look the same. Only the port makes one of them “grab”. |
| The motor (the jaws) | A | One motor with its own job goes in A. |
Swap these two cables and nothing will look wrong. No error, and no warning. The clamp will just open when you wanted it to grab. Lesson 38 showed this too. It is worth learning twice.
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 is best for this model. You carry a clamp to the thing it picks up. A USB cable keeps it stuck at the desk. If you only have USB, download the program and unplug. Then run it from the Brick’s own screen.
Make one change at a time, and guess what will happen before each run. The first one is the most important, so do it carefully.
Step 6 is the edge of what you can do so far. The program needs to ask a question: is it already closed? Then it must do one thing or another, by the answer. None of the blocks you know can ask a question.
That block does exist. It is called Switch. It looks like if <> then … else …, and you meet it soon. It comes in Lesson 43, the Gyro Magic Stick. So far, your robots have done what they are told, in order. Soon, your robots start making choices.
Thirty-nine models, and this one needs something you do not have yet. That is not a gap. That is a door to open next.

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.
Two stacks, six blocks in all. Neither stack starts the program. Each one waits for its own button.
Use your own number instead of the 90s. Take the degrees you wrote down in section 8. Use a little less, so the jaws stop just before they hit the end.
[1 v] when [pressed v] :: events hat [A v] set speed to (30) % :: motors [A v] run [clockwise v] for (90) [degrees v] :: motors [2 v] when [pressed v] :: events hat [A v] set speed to (30) % :: motors [A v] run [counterclockwise v] for (90) [degrees v] :: motors
Go through it the way the Brick sees it:
Do your jaws close when you wanted them to open? Do not change the program yet. First check the two cables are the right way round. If they are, swap
[clockwise v]and[counterclockwise v]— which way the jaws move depends on how you built the motor in. With no guide, yours may be different from your neighbour's.
What success looks like: you hold the clamp in one hand. You close it on a pen with your thumb. You let go with a finger. And you do not need to look at the computer.
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.
Pick something up. Carry it across the table. Put it down again. Do not drop it. Do not squeeze it too hard. Choose the thing yourself. Be ready to say why you chose it. Something hard and something soft will not need the same grip.
Make the clamp tell you what it did. Each button must give a different sound. Each must show a different message on the Brick screen. Then a person can tell what they just did without looking at the jaws. Then give it to someone who has not seen it. Watch to see if they can work it out.
Make the clamp safe to forget. Someone might press grab five times in a row. Nothing must break. You cannot stop the motor being told to close. So you must change how far and how hard it closes each time. Tell us what you changed and what it costs you. It does cost you something.
Design a gripper that someone else can use with no help. You have used your own clamp all lesson. So you know what it does. That is just why you are the wrong person to judge it. Your job is to make it easy for a stranger to use. Plan on paper before you change anything. Decide where the buttons should sit for a hand that is not yours. Decide what the clamp should do as soon as it is switched on. Then you know if it is open or shut. Decide how it tells its user what is going on. Then test it properly. Give it to someone from another group. Tell them nothing. Give them a thing to pick up. Watch, and do not help. Write down every time they stop to think. Two questions when you show it. What did your tester get wrong? What did you change because of it? And your clamp still does not know if it is open or shut. Say you had a block that could ask a question. What would you do?