The Cyclist: a rider on a bike. A Large Motor turns a crank, and the crank turns the rider’s legs. It is just like real legs turning real pedals.
Run it the way you have run everything so far. It jumps from standing still straight to full speed. That looks wrong. You know why from your own body. Nobody starts a bike at racing speed.
Today you make the motor speed up bit by bit, then slow down again. That is what makes a machine look alive, not just switched on.
In the real world 5 min
Where you have seen it
Watch anyone set off on a bike. The first few turns of the pedals are slow and heavy. They stand on the pedals to get going. Only when the bike is rolling do the legs find a steady beat. Stopping is the same, but backwards.
A cyclist on Des Voeux Road Central, Hong Kong. Photo: Adsworldra / Wikimedia Commons (CC BY-SA 3.0).
Why it is built that way
The rider has no choice. A bike and rider are heavy. Anything heavy does not want to speed up. That is called inertia. The heavier the thing, the longer it takes to get up to speed with the same push.
So a full lorry pulls away from traffic lights slowly, but a motorbike does not. A train takes a kilometre to stop. None of them are being gentle on purpose. They are all just heavy.
What would go wrong without it
Make a heavy thing change speed all at once, and something has to give. A train that stopped dead would throw everyone down the carriage. A model that starts all at once does the same, just smaller. The crank jerks. The rider’s legs slam round. The whole machine hops on the table.
Speeding up takes effort. If you pretend it does not, things break.
The main concept — changing a speed that is already running 6 min
Every motor block you have used so far started something. This one changes something that is already going.
[A v] start motor at (20) % speed :: motors
wait (1) seconds
[A v] set speed to (60) % :: motors
The motor never stops between those blocks. It turns at 20, then it turns at 60.
Look at what is not there. No second start. No stop. The motor was already running. set speed to just changed its speed while it ran.
Block
What it does
start motor at () % speed
Sets the motor going, then goes straight on to the next block. It does not wait. The motor keeps running until something stops it.
set speed to () %
Changes the speed of a motor that is already turning. It happens straight away. It does not start or stop anything.
stop motor
Stops it. How it stops depends on the stop setting. You will use it at the top of today’s program.
A ramp is just a few of them in a row
A speed that goes up in steps is called a ramp. Put a wait between each change. Now you have a staircase of speeds. Make the steps small and close together. Then it stops looking like steps at all.
[A v] start motor at (20) % speed :: motors
wait (0.5) seconds
[A v] set speed to (40) % :: motors
wait (0.5) seconds
[A v] set speed to (60) % :: motors
wait (0.5) seconds
[A v] set speed to (80) % :: motors
Four speeds in a second and a half. The rider speeds up bit by bit. It does not jump to full speed.
ComponentMotion4 min
Speed and power
Speed is set separately from movement. You tell the motor how fast it should go, and then you tell it to go — two blocks, in that order.
Speed is a percentage of what this motor can do, not a real-world unit — the same 50 % moves a light arm quickly and a heavy one slowly.
Blocks reference
Block
What it does
[A v] set speed to (25) % :: motors
Sets the speed for this motor from now on. Nothing moves — it only changes what the next movement will do.
[A v] run [clockwise v] for (2) [rotations v] :: motors
Now moves, at whatever speed was last set.
Set it first
when program starts :: events hat
[A v] set speed to (25) % :: motors
[A v] run [clockwise v] for (2) [rotations v] :: motors
Swap those two blocks round and the program still contains a speed of 25 % — it just never gets used. Both shafts below are asked for exactly 2 rotations; watch how long each one takes.
speed first — works
A set speed to 25 %
A run clockwise for 2rotations
speed last — does nothing
A run clockwise for 2rotations
A set speed to 25 %
0.00rotations · slow0.00rotations · fast
Speed first: the movement was slowSpeed last: it only affects the NEXT movement
Two programs. Same two blocks in each — only the order is different.Both are running — and the right-hand one is already finished. The left is barely a third of the way.Its speed block runs now, far too late to affect the movement above it. The left motor is still going, slowly, as it was told to.Both turned exactly 2 rotations. Only one of them did it at the speed the program asked for.Finished — it will run again in a moment.
stopped
Both shafts turn exactly 2 rotations. Only the time they take is different — and the right-hand program never gets the slow movement it was written to have.
The right-hand movement is over before the left is a third of the way round, because it ran at the default speed. Its set speed to () block does run — you can see it light up — but by then the movement it was meant to slow down has already happened. A speed block only ever affects the movements after it. This catches people out constantly.
Slow is often better
A high speed is not a better program. Slow movements are gentler on the gears, easier to watch and debug, and look more like the real machine — a barrier that snaps up in a fraction of a second reads as broken rather than fast.
A ramp is not a special block. It is the same block, used again and again, on a motor you never stopped.
▶Where the waits come fromThe wait block. And why seconds are right for a ramp, when they were wrong for the Rickshaw.Show meHide
ComponentControl4 min
Waiting
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.
Blocks reference
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.
One wait for every sensor
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.
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.
When there is no ready-made block
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.
Guessing, or knowing
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
start moving straight: 0
wait 2 seconds
stop moving
wait for a condition
start moving straight: 0
4 wait until distance <15cm
stop moving
60cm left · timed60cm left · sensed1run
Timed: 60 cm — a different answer againSensed: 15 cm, as asked
Both robots start driving towards the wall.The left one is counting two seconds. The right one is watching the wall come closer.Both have stopped. Only one of them stopped somewhere it chose.Watch where the timed robot ends up on the next run, and the one after that.Finished — and it will bet again in a moment.
both stopped
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.
wait () seconds is a guess. You are betting that two seconds is long enough. On a fresh battery, on a smooth floor, it might be — and then it is not.
wait until is knowing. The robot carries on the moment the thing has actually happened, however long that takes.
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.
Why it matters
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.
Yes, seconds, even though the Rickshaw said not to. That was Level 1, Lesson 42. It was about distance: how far the rickshaw went. A ramp is about how long the change takes. That really is an amount of time. Seconds are wrong for measuring how far you go. They are just right for how fast you speed up.
Say this back before moving on: “Set speed changes a motor that is already running.”
What’s in this build 4 min
Part
What it is doing here
EV3 Intelligent Brick
Runs the ramp. It is also most of the model’s weight. The motor has to push against that weight every time the speed goes up.
Large Motor, the pedals
Turns the crank that moves the rider’s legs. It is a Large Motor, not a Medium one. A crank with rods on it is harder work than it looks.
The crank and linkage (not electronic)
Turns round-and-round into a pedalling move. In every turn there is a heavy spot and a light spot. That is why a jerky start shows up so much on this model.
Feel how hard it is to turn, before you program it
Turn the crank slowly by hand, one full turn. It is not just as hard all the way round. Find the heaviest spot.
Now turn it fast. Once it is going, it wants to keep going. That is the same inertia the motor has to deal with.
Stop it dead with your finger. Feel how much it pushes back. A sudden stop does that to your gears.
Leave the crank at its heaviest spot before your first run. A ramp that starts from the hardest spot is a fair test.
Ports — and the rule 4 min
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
Pedal motor (Large)
A
One motor doing one job. It is not a pair of wheels, so use Motor blocks, not Movement blocks.
Sensors
none
The Cyclist cannot tell how fast it is really going. It only knows what it was told. Remember that when you get to the challenges.
Check your own build now:
Pedal motor into A.
Hold the model down, or clamp it. If it hops, you cannot judge the ramp.
Check the rods never hit the cable, all the way round the turn.
Connect the Brick 4 min
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.
▶How to connect the BrickUSB and Bluetooth, step by step, with a photograph of every screen. Open it if you have not done this before — or if pairing is not working.Show meHide
USB — the reliable one
Switch the Brick on with the dark grey centre button.
Cable into the Brick’s PC port — the small square socket beside the numbered ports, not one of the numbered ones.
Other end into the computer.
Bluetooth — name it first
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.
Name your Brick. On the Brick: Settings (the spanner) → Brick Name. Type something nobody else will pick, then press the tick. Every Brick is called EV3 until somebody changes it.
Turn Bluetooth on. Settings → Bluetooth. Tick Bluetooth and Visibility. Leave iPhone/iPad/iPod unticked.
Connect from EV3 Classroom. Click the Brick icon at the top of the programming area, find your Brick by name, and click Connect.
Say yes on the Brick. It asks “Connect?” with the computer’s name — choose the tick, then accept the passkey, which is already 1234.
Where to read it. The name sits in the bar across the very top of the screen, on every screen — so you can check which Brick you are holding at any moment without going into a menu. This one is EV3VE. A Brick nobody has renamed says EV3.Step 3, and the reason step 1 exists. Three Bricks in range — read the name before you click Connect. Pairing with the wrong one is not an error: it works perfectly, on somebody else’s robot.
Step 2.Bluetooth switches the radio on; Visibility is what lets the computer find you. With Visibility off your Brick works perfectly and simply never appears in the list.Step 4. Look at the Brick. It asks whether to accept and names the computer. Choose the tick.Then the passkey, already 1234. Press the tick again and you are connected.
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.
USB is fine. The Cyclist stays on the table. You will change numbers and run it again a lot today. A cable makes that faster.
Confirm the connection 2 min
Check the Brick icon: connected, or not.
One Large Motor tile on A. Does it say Medium? Then the wrong motor is in the model.
Turn the crank by hand and watch tile A count.
Turn it fast, then slow. Watch the tile’s speed number, not just its degrees. Your program is about to control that number.
Change it and test 8 min
Make one change at a time, and listen. This lesson is easier to hear than to watch.
Delete every block except start motor at (60) % speed, a wait, and a stop. Now it goes straight to riding speed, with no ramp. Watch the model jump. Then put the ramp back.
Halve every wait in the ramp. Use 0.5 instead of 1. It speeds up faster. When does it stop looking smooth?
Add two more steps on the way up: 15, 25, 35, 50, 60. More steps, same total time. Is it smoother, or just longer?
Take out the slowing-down part, but leave the stop. The rider goes from riding to nothing. With coast set, watch how far the crank keeps going by itself.
Change the stop setting to hold position. Run step 4 again. Now it stops dead. Which one looks like a bike?
Step 5 is where two ideas meet. The ramp decides how it gets up to speed. The stop setting decides how it stops. You will meet it again in Lesson 26, the Crossbow. A good machine needs both. You cannot see either one in a program that only says run for 2 rotations.
How a machine gets up to speed is something you choose. It matters as much as the speed itself.
Build it 15 min
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.
This is what you are building: the Cyclist.
Make it move 10 min
A whole ride. Set off gently. Build up to riding speed and hold it. Then slow down and stop.
when program starts :: events hat
[A v] set motor to [coast v] at stop :: motors
[A v] start motor at (15) % speed :: motors
wait (1) seconds
[A v] set speed to (35) % :: motors
wait (1) seconds
[A v] set speed to (60) % :: motors
wait (3) seconds
[A v] set speed to (30) % :: motors
wait (1) seconds
[A v] set speed to (10) % :: motors
wait (1) seconds
[A v] stop motor :: motors
Up in three steps. Ride for three seconds. Down in two steps, then stop. Twelve blocks, one motor, and it keeps turning until the end.
coast at stop. This is the stop setting. It tells the motor how to stop. Coast means it rolls to a stop on its own, like a bike. Set this once at the top, and the ending looks right with no extra work.
start motor at 15%. Only just moving. This is the rider pushing hard on the pedals to get going.
35, then 60. Speeding up. The motor never stops. Only the number changes.
wait 3 seconds at 60. Riding along. This is the longest wait in the program. It is the part that looks like "riding", not "starting".
30, 10, stop. Slowing down, then rolling to a stop.
What success looks like: look away, and you can still hear the ride. The motor sound goes up, stays, then goes down. Nothing should sound sudden.
Does the model jump at the start? Then your first speed is too high for the crank's heavy spot. Change the 15 to 10. Add another half-second before the first change.
Challenges 27 min
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.
Challenge 1
Put a speedometer on it. A speedometer shows how fast you are going. Take the ramp from the lesson. At every step, write the new speed number on the Brick's screen. Send it to the motor as well.
The Brick is not on the model. It sits beside it, joined by one cable. So the screen is the only place that number ever shows. Someone standing back should be able to read the whole ride off the screen. They should not need to look at the crank at all.
Success looks like: the number on the screen changes just as the motor sound changes. If the screen changes late, your display block is in the wrong place.
Challenge 2
Give it a throttle. A throttle is the control that sets the speed. Use the Brick's Up and Down buttons to change the speed. Do it while the motor is still running. Up adds 10%. Down takes 10% away. Keep the screen showing the speed at all times.
Start at 30%. Do not let it go past 100% or below 0. What should happen if someone keeps pressing at either end? You decide.
Success looks like: you can speed the Cyclist up to full and back down to a stop. You only use your thumbs. And the screen always agrees with your ears.
Challenge 3
Now make the throttle smooth. A press of Up should not jump straight to the new speed. It should ease there over about half a second. That is just how the ramp in the lesson eases from one number to the next.
This is the lesson's idea, moved from a fixed program to a control. The speed the rider asks for is one number. The speed the motor is going is another number. Your program has to move the second number towards the first, a little at a time.
Success looks like: hold Up down, and the machine speeds up the way a real bike does. Nothing in the moving parts should jump, at any speed you can reach.
Extra challenge
Turn the Brick into a bike's handlebars.
Right now the Brick is a box running a fixed program. Make it the thing a rider holds. Up and Down are the gears. The screen is the speedometer. The centre button is the bell.
Plan it on paper before you build any of it. Write down what each button does. Write what the screen shows and what the rider hears. Then sort out the tricky cases nobody plans for. What should the bell do when the bike is stopped? What does Down do when the speed is already zero? Should every gear change be the same size? Or should the first one be gentler than the rest?
Now build just what you wrote. Hand the Brick to someone who has not seen your notes. If they can work out the controls by themselves, the design is good. If you find yourself explaining it, change the machine, not the explanation.
Remember what this model is and is not. The Cyclist does not go anywhere. The crank turns on the spot, and the Brick sits beside it on a cable. So "speed" here means how fast the rider is pedalling. Everything people learn about it has to come from that screen or that speaker.
When you show it, answer two questions. Which tricky case did you get wrong the first time, and how did you find out? And the Large Motor already knows how fast it is really turning. It has a rotation sensor inside it. Show the speed it is REALLY going. Put it next to the speed you asked for. How would you do it? The crank has a heaviest point. As the crank goes over it, what will the gap between the two numbers do?