Challenge 1
Open the door to exactly 5 cm. Then open it to exactly 10 cm. Use the ratio you measured. Check both with a ruler.
Quick Learn — the model, the instructions, the program and the challenges. The theory is in Full Lesson.
EV3 Robotics›Level 2 · Intermediate›Lesson 33
Level 2 · Lesson 33 · EV3-L02-3360 minutes · Ages 8+ · Model: Auto Folding Door
The Auto Folding Door is a zig-zag of beams. It is called a scissor linkage. The Brick is at one end. A little cart on wheels is at the other. A Medium Motor drives the cart.
Drive the cart away from the Brick. The zig-zag pulls flat, and the doorway closes. Drive it back, and the zig-zag folds up small.
By the end, the door will open when someone comes. It will close behind them. You will also find how far the motor turns to move the door one centimetre.
The doors on a city bus fold. They do not slide. They have to fold. A bus has no room beside the doorway for a door to slide into. So the door folds up inside the doorway.

A scissor linkage makes a small move into a big move. Push the two ends of one X together. The far end moves further than your hand did. Join lots of Xs, and it grows even more. The more X pairs, the more the end moves for the same push.
But nothing is free. What you gain in distance, you lose in force. A motor might hold a heavy door on its own. With ten X pairs, it will struggle. The tip moves ten times as far, but with a tenth of the push. You swapped speed for force in Lesson 4, the Strong Lifter. This is the same swap, with beams instead of gears.
You can see this trick in lots of places. A scissor lift on a building site uses it. So does a folding baby gate. So does a grabber toy that shoots out when you squeeze it. So does the arm on top of some trains.
Here is today’s big idea. Ask the motor for one turn, and you do not know how far the door moved. The zig-zag sits in between and changes the answer. Add a pair of Xs, and the same turn moves the door further. The program did not change.
The number in a motor block counts the motor. The job counts the door.
Every program you have written tells the motor what to do. But every job is about the other end of the machine. Most of the time, the two are close enough. Here they are not.
| The program says | The world says |
|---|---|
run for (700) degrees | the doorway opened about 12 cm |
run for (350) degrees | half as much: about 6 cm |
| add one more pair of Xs to the lattice | the same 700 degrees now opens further, and no block changed |
That number is for your model and nobody else’s. Another group may have one more pair of Xs. Or a different wheel on the cart. They will get a different number, and both are right. This time you cannot work the number out from the parts. You have to measure it.
You can. For one door, it is quicker. But the ratio helps when you want two places, like half open and fully open. It also helps when someone rebuilds the zig-zag. With a ratio, you just do the sum again. Without one, you start guessing all over again.
You did the same maths for a driving robot in Lesson 16, the Card Dealer. There, a wheel did the change, not a zig-zag. That one was easier. You could work it out from the size of the wheel. The idea is the same.
A scissor mechanism is pairs of bars crossed like an X and pinned through their middles. Squeeze the bottom corners together and the whole thing grows taller; pull them apart and it folds back down. It turns a small sideways movement into a large movement at right angles to it.
Each X contributes a height, and stacking them adds those heights up. For links of length L at an angle θ above horizontal:
height = stages × L × sin θ · base span = L × cos θ
So more stages means more height for exactly the same squeeze — which is why an extending arm gets dramatic very quickly. Each stage costs a pair of links, four pins and a little more wobble.
The force bar is the part builders meet in real life: a scissor lift that will not start from flat is not underpowered, it is being asked at its worst angle.
A scissor lift is hardest to start. When the links are nearly flat, a big sideways push produces only a small sideways movement of the pins but a huge rise — and the force needed to hold the load goes up correspondingly. As it rises and the links steepen, the job gets easier and easier.
This is why a LEGO scissor lift so often sits there straining at the bottom and then flies up once it is moving. The motor is not underpowered; it is being asked at the worst possible angle. Three ways out, in order of how well they work:
Something has to pull the bottom corners together. A lead screw or a worm drive is the usual answer, because both are strong and cannot be back-driven — the lift holds its height when the motor stops instead of sinking under the load.
Whatever drives it, the movement ends against something: fully folded, or fully extended. Drive to either of those with a timed motor block, never with degrees. A measured block waits for a shaft that has stopped turning, and the program hangs there for ever.
Scissor lifts raise people to work at height, lift cars in a garage, and sit under the beds of tipping trucks. The same linkage extends a folding gate, a lazy-tongs grabber, and the arm on a magic-trick boxing glove.
Every EV3 motor contains a sensor that counts how far it has actually turned. That means a motor is not only an output — you can ask it where it is, and the answer describes what really happened rather than what you asked for.
| Block | What it does |
|---|---|
([A v] degrees counted :: sensors) | Reports how far this motor has actually turned since the count was last reset, in degrees. |
[A v] reset degrees counted :: motors | Sets the count back to zero, making right here the new reference point. |
([A v] speed :: sensors) | Reports how fast the motor is turning right now, as a percentage. A motor that is being driven but reads zero is a motor that is stuck. |
Those two are not always the same. Here are two identical motors, running the same program, with only their mechanisms different.
the same program, on two identical motors
Nothing on the Brick announces a stall. The only evidence is that the counter stopped changing while the motor was still being told to turn.
Nothing on the Brick announces the jam. The motor is still being driven, the program is still sitting on the same block, and the only trace of the problem anywhere is a counter that has stopped climbing. Comparing what you asked for with what was counted is how a robot notices — which is the whole of stall detection.
When the Brick powers on, the count is simply whatever it happens to be. It is not a position on the machine — it becomes one only when you tie it to something physical.
That is what reset degrees counted is for, and it is not just a tidy-up block for the top of a program. Where you put it decides what zero means, so putting it part-way through — after the mechanism has been driven somewhere known — is the normal way to use it, not an abuse of it.
A conveyor has no idea where it is. Give it a touch sensor at one end and it can find out: drive it until the sensor is pressed, and it is now at a place you can name. Only then reset the count, and that end becomes 0.
when program starts :: events hat [A v] start motor [counterclockwise v] :: motors [1 v] wait until [pressed v] :: sensors [A v] stop motor :: motors [A v] reset degrees counted :: motors
The order is the whole point. Reset before the sensor is pressed and you have zeroed a random spot; reset after it, and every later reading means “how far from home”. This is called homing, and it is why a printer rattles its head to one side when you switch it on.
Drive towards home gently. The mechanism is deliberately being run into its own end stop, so a slow speed saves the gears — and the touch sensor is what stops it, which means it stops in the same place every time regardless of where it started.
Home is often a corner, and a corner is an awkward place to measure from. Say the conveyor carries a chute that dispenses bricks, and you would rather describe its position as left and right of the middle. Then home once, drive the known distance to the middle, and reset again there:
when program starts :: events hat [A v] start motor [counterclockwise v] :: motors [1 v] wait until [pressed v] :: sensors [A v] stop motor :: motors [A v] reset degrees counted :: motors [A v] run [clockwise v] for (900) [degrees v] :: motors [A v] reset degrees counted :: motors
Now the middle is 0. Moving right counts up, moving left counts down past zero into negative numbers — the count is perfectly happy to go negative — and “go back to the middle” becomes the simplest instruction in the program: drive until the count reaches 0.
Both resets earn their place. The first one turns a meaningless number into a distance from a real, repeatable place. The second one moves zero to where the maths is easiest. A reset in the middle of a program is only a mistake when the mechanism is somewhere you cannot name.
Because the count is in degrees, and a wheel of known size travels a known distance per turn, the reading can be converted into how far the robot has actually driven. That is how a robot reports a distance in centimetres rather than in rotations — and it is why changing the wheels changes the answer.
This is how a printer knows the paper jammed, how a car window stops when it meets your hand, and how a robot arm knows it has reached its limit. A machine that can only give orders is fragile; one that can check what happened can recover.
Find out how many degrees make one centimetre, once. Then program in centimetres.
Two meshed gears are a bargain. Whatever one of them gains in turns it loses in force, and whatever it loses in turns it gains in force. There is no arrangement of gears that gives you more of both, and no amount of building will find one.
Count the teeth on the gear you are turning (the driver) and the teeth on the one being turned (the follower). That is the whole calculation:
turns out = turns in × driver teeth ÷ follower teeth
An 8-tooth gear driving a 24 gives ⅓ of a turn out for every turn in — and three times the turning force. Turn the pair round and you get three turns out and a third of the force. Count the turns yourself below.
The number of teeth is the whole story. 8 teeth driving 24 means 8 ÷ 24 of a turn out for every turn in — and the force changes by exactly the opposite amount.
| Arrangement | Turns | Force | What it is for |
|---|---|---|---|
| Gearing down — small driving large | fewer | more | winches, lifts, robot arms, anything that has to move a weight |
| Gearing up — large driving small | more | less | fans, spinners, launchers, wheels on a light fast robot |
| 1 : 1 — same size | same | same | moving the drive to a different axle, or fixing a direction |
The names are worth getting right because they are backwards from what people expect: gearing down makes the output slower, not smaller, and it is the setting that makes a weak motor able to lift things.
Put several pairs in a row and the ratios multiply. Two 1:3 reductions in series give 1:9 — which is how a Medium Motor ends up able to raise something it could never shift directly. This is also how a gearbox with a sensible number of parts reaches a ratio that a single pair never could: a 40-tooth gear driven by an 8 is 1:5, and doing it twice is 1:25.
Only the first and last gear affect the ratio. Anything in the middle passes the motion along and changes nothing but the direction — which is a whole idea of its own, in Changing the direction of a turn.
Every mesh loses a little to friction, so a long train is less efficient than a short one. Gearing down far enough to lift a heavy load also makes the mechanism slow, and slow is not always acceptable. And a gear train that is geared down hard is very hard to turn backwards by hand, which is either a useful brake or a nuisance depending on what you are building.
A bicycle is the same idea with a chain instead of teeth in mesh: the low gear that gets you up a hill is turning the back wheel slowly and pushing hard, and the high gear you use going downhill does the opposite. Cars, drills, cranes and clocks are all making the same trade.
Say this back before moving on: “The motor counts degrees. The door is measured in centimetres. Somebody has to convert.”
Look at your model. Count the X pairs in the zig-zag. That number changes what your machine does. But it is not in any program.
| Part | What it is doing here |
|---|---|
| EV3 Intelligent Brick | The door post. It does not move. One end of the zig-zag is fixed to it. It must not slide, because everything is measured from here. |
| Medium Motor | Drives the cart along. Its encoder is the only thing that knows where the door is. It counts in degrees of motor, not of door. |
| Ultrasonic Sensor | Watches the way in. It is looking for a person. So it must look along the path people walk, not across the doorway. |
| The scissor linkage (not electronic) | Makes the move bigger. Each X pair you add moves the far end further for each turn of the motor. It also makes it weaker. |
| The cart and its wheels (not electronic) | Turns the motor’s turning into moving along. Bigger wheels move the door more for each degree. That changes your ratio too. |
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 |
|---|---|---|
| Cart drive (Medium Motor) | A | One motor doing its own job. |
| Approach sensor (Ultrasonic) | 4 | The Ultrasonic always goes here. |
Check your own wiring 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.
The Brick holds this model up. One end of the zig-zag is fixed to it. If something pulls the Brick, the door’s starting point moves. Lay a USB cable so it cannot pull the Brick sideways. Or use Bluetooth.
Stuck? There is a photo of every screen in the Brick & Bluetooth guide.
One change at a time. Keep a ruler by the door. Most of today’s answers are in centimetres.
Step 3 is the one to remember. Nothing in the program was wrong. But the machine did something different. The program needs a number that was never in the program. It was in the plastic. Write your ratio on a card and keep it with the model.
If you guess numbers until they work, they only work on that one machine.

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.
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.
Open when someone comes. Stay open while they pass. Close when they have gone.
when program starts :: events hat [A v] reset degrees counted :: motors clear display :: display write [DOOR READY] at line (1) :: display forever [4 v] wait until distance [< v] (30) [cm v] :: sensors write [OPEN ] at line (1) :: display [A v] run [clockwise v] for (700) [degrees v] at (40) % speed :: motors wait until <([4 v] distance in [cm v] :: sensors) > (50)> wait (2) seconds write [CLOSE ] at line (1) :: display [A v] run [counterclockwise v] for (700) [degrees v] at (40) % speed :: motors end
What success looks like: move a hand towards the door. It folds open. It waits while your hand passes. It waits two seconds more. Then it folds shut, back to just where it started. It is not a little more open each time.
Does the door open a bit more each time? Then it hits its end on the way out and gets stuck. It loses that bit on the way back. Use a few less degrees. The safe distance is a little less than the full distance.
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.
Open the door to exactly 5 cm. Then open it to exactly 10 cm. Use the ratio you measured. Check both with a ruler.
Make the door open only as far as it needs to. Open it a little for a hand. Open it all the way for a whole box.
Add one X pair to the lattice, or take one away. The lattice is the criss-cross part that folds. Measure your ratio again. Then get the door back to exactly 10 cm.
Build a door with two speeds. It opens fast until it is 80% open. Then it opens slowly for the last part. It closes slowly all the way. It must end up exactly closed every time. Prove it. Run twenty open-and-close cycles. Then measure where it closed.