The Crazy Pirate Ship: the fairground ride from Lesson 8, except this one can go all the way over the top. A tyre in the middle drives the ship, and two Touch Sensors — one left, one right — let a person push it either way.
You cannot get it round with one long push. The motor is not strong enough and never will be. You get it round by pushing in the right direction at the right moment, over and over, until each swing is bigger than the last.
Which means a person has to be at the controls, watching. And that breaks something about every program you have written so far: a single column of blocks, running top to bottom, cannot watch two buttons at once.
In the real world 5 min
Where you have seen it
The swinging ship is in every theme park from Genting to Sunway Lagoon. The gentle ones swing to about forty-five degrees. The ones with a queue go past vertical and hang you upside down at the top.
A swinging ship ride on its A-frame pivot, Leofoo Village Theme Park. Photo: milst1 / Wikimedia Commons (CC BY-SA 2.0).
Why it is built that way
The ride does not have a huge motor. It has a small one and a driving wheel pressed against the underside of the ship — exactly like the tyre in your model — and it uses the same trick you met with the Clock Ticking in Lesson 12.
Each push is small. But a push given while the ship is already moving the same way adds to the swing, and a few dozen of those build up to something enormous. That build-up of motion is momentum, and it is stored in the swing itself rather than in any part of the machine.
What would go wrong without it
Push at the wrong moment and you do not just waste the push — you take energy out. A shove against a ship that is coming towards you slows it down.
So the operator has to react to what the ship is doing right now, continuously, in both directions. A machine that could only be told one thing at a time would be no use to them at all.
A machine a person drives has to be listening the whole time — not working through a list.
Before you build 1 min
This model has no step-by-step manual, and the video below is not one. It is a film of a finished Crazy Pirate Ship going over the top. Watch it for the target — and watch what the driving tyre does at the moment the ship changes direction — then build from the model your teacher has. You are not missing a page; the page does not exist.
The main concept — more than one stack 6 min
A program does not have to be one column of blocks. You can put down several separate stacks, each with its own hat, and the Brick runs them all at the same time.
Every program you have written has started with one hat: when program starts. There are others, and they wait for other things.
Hat block
Its stack runs when…
when program starts :: events hat
the green flag is pressed. Once.
[1 v] when [pressed v] :: events hat
the Touch Sensor in port 1 is pressed — every time, for as long as the program is running.
when [center v] button [pressed v] :: events hat
a button on the Brick itself is pressed.
A sensor hat is not the same as wait until, and the difference is the whole lesson. Wait until stops the program at one spot until one thing happens, once. A hat sits there for the whole run and fires its stack every single time.
the program starts — all of these begin here
stack 1 · Medium Motor
when program starts
A start motor clockwise
stack 2 · status light
when program starts
forever
set status light to green
wait 0.5 seconds
set status light to red
wait 0.5 seconds
stack 3 · drive base
when program starts
start moving straight: 0
One stack, one jobAll three at once
Three stacks, each with its own hat block. All three start the moment the program starts — none of them waits for the others.All three are running in the same instant: the Medium Motor is turning, the light is flashing, and the drive base is rolling.Each stack owns one thing and never touches another stack's job. That is the rule that makes this work.Finished. All three jobs ran the whole time, and none got in another's way.
three stacks, three jobs
Every stack is highlighted at the same moment on purpose — that is what running in parallel looks like. The switch above changes only what the third stack controls.
Notice how the demo is drawn: the stacks are side by side under one starting bar, not stacked in a column. Nothing in one stack is “before” anything in another. They are simply all live.
One stack per thing that can happen. That is how a program listens to two buttons at once without ever asking “which one?”
One rule comes with it: one owner per motor. If two stacks both try to drive port A at the same moment, the last one to speak wins and the result is nonsense. Today that is safe, because a person only presses one button at a time — but it is the trap waiting for you the moment you add a third stack.
▶Two things at once, and the Touch SensorThe full reference for parallel stacks and for the switches this model uses. Open either if it is not clear yet.Show meHide
ComponentControl5 min
Two things at once
A program does not have to be one long column of blocks. Several stacks can run at the same time, each doing its own job — one driving, one watching a sensor, one keeping the display up to date.
How it is done
Give each stack its own hat block. Every stack beginning with when program starts starts at the same instant — not one after another — and from then on they run alongside each other.
Nor is it limited to two. Below, three stacks run together: a Medium Motor turning an attachment, the status light flashing, and the drive base rolling. Watch the arrows at the top — they all begin at once, and no stack waits for any other.
when program starts :: events hat
[A v] start motor [clockwise v] :: motors
when program starts :: events hat
forever
set status light to [green v] :: display
wait (0.5) seconds
set status light to [red v] :: display
wait (0.5) seconds
end
when program starts :: events hat
start moving [straight: 0] :: movement
Written down they have to go one under another, because a page is a column — but that is an accident of paper. On the Brick they sit side by side, and nothing in the first stack happens before anything in the third.
The rule: one owner per thing
Parallel stacks go wrong when two of them try to control the same thing. Use the switch below to take the wheels away from the third stack and point it at motor A, which the first stack is already driving.
the program starts — all of these begin here
stack 1 · Medium Motor
when program starts
A start motor clockwise
stack 2 · status light
when program starts
forever
set status light to green
wait 0.5 seconds
set status light to red
wait 0.5 seconds
stack 3 · drive base
when program starts
start moving straight: 0
One stack, one jobAll three at once
Three stacks, each with its own hat block. All three start the moment the program starts — none of them waits for the others.All three are running in the same instant: the Medium Motor is turning, the light is flashing, and the drive base is rolling.Each stack owns one thing and never touches another stack's job. That is the rule that makes this work.Finished. All three jobs ran the whole time, and none got in another's way.
three stacks, three jobs
Every stack is highlighted at the same moment on purpose — that is what running in parallel looks like. The switch above changes only what the third stack controls.
With one owner each, all three stacks are highlighted at the same instant and all three jobs get done. With two owners, motor A is handed contradictory orders hundreds of times a second and shivers instead of turning — and notice the second cost, which is easy to miss: the wheels now have nobody driving them. A stack that goes to fight over someone else’s motor has abandoned its own job. Nothing reports an error either way; as far as the Brick is concerned every stack is working perfectly. The same happens to a display line or a variable that two stacks both write to.
The discipline is simple: give each stack sole ownership of what it controls. One stack owns the motors, another owns the screen, another watches the sensors and tells the others what it found — which is what broadcasting is for.
ComponentSensing5 min
The Touch Sensor
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.
released
pressed
The red button out, and the same sensor with it pushed in. These two states are the entire output of this sensor — there is nothing in between.
Blocks reference
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.
Three different events
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.
when program starts
forever
if 1 is pressed? then
change count by 1
versus two hat blocks
1 when pressed
1 when bumped
0is pressed? in a loop0when pressed0when bumped
In a loop: 0 answers from one pressBumped: exactly one
Nobody is touching the sensor. All three programs are watching it.A finger presses the button. Watch the red button go in — a couple of millimetres is the sensor's entire movement.The finger is still down. The loop checking «is pressed?» has already run hundreds of times, and every one of them counted.The finger lifts. Only now does «bumped» count, because bumped means pressed AND released.One press. Three completely different answers.Finished. The same press, counted three ways.
released
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:
Pressed — the button is down right now. Good for “hold to run”.
Released — it is up again. Good for acting when somebody lets go.
Bumped — pressed and released. This is what you want for “click to start”, because it will not fire repeatedly while a finger stays down.
The classic bumper
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.
Why it matters
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.
Say this back before moving on: “Each hat starts its own stack, and they all run at the same time.”
What’s in this build 4 min
Four parts with cables. And again, you have to tell us which motor it is — no manual, no verified parts list.
Part
What it is doing here
EV3 Intelligent Brick
Runs the program. It is also the heaviest thing in the frame, so it is what stops the whole model rocking off the table when the ship swings.
One motor — you decide which
Turns the driving tyre. Goes in port A, and every program below says A.
Touch Sensor ×2
Left and right. Identical parts, told apart only by port — the lesson you just had with the Machine Gun.
The driving tyre (no cable)
Presses against the ship and pushes it along. It only works where it touches, which is why timing matters so much.
Find the ship’s own rhythm
Brick off. You met this routine with the Clock Ticking.
Pull the ship to one side and let go. Do not push it.
Count ten complete swings — over and back is one — and time them. Divide by ten. That is the ship’s period.
Watch where the ship is slowest. It is at the two ends, where it stops and turns round. And it is fastest at the bottom.
Now decide, before you touch a button: to make the swing bigger, should you push when it is at the bottom moving away from you, or when it is at the top?
Step 4 is the whole game. Push with the movement, at the moment it is already moving fastest. Push against it and you are braking.
Ports — and the rule 4 min
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
The motor (drives the tyre)
A
A single working motor takes A, as it has all course.
Touch Sensor — left
1
Touch is always port 1 in this course.
Touch Sensor — right
2
The second one borrows the Gyro’s slot, same as the Machine Gun. There is no Gyro here to mind.
Check your own build now:
Motor cable in A. A letter.
Label the two sensor cables 1 and 2 with tape before you plug them in, exactly as you did last lesson. Left is 1.
Is the driving tyre actually touching the ship? Firmly enough to grip, loosely enough that the ship swings freely when the motor is off. That balance is the fiddliest part of this build.
Swing the ship by hand through its full arc. Does anything catch? There must be nothing in the way at the top — that is where you are trying to get it to.
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.
Keep every cable out of the ship’s arc. This model swings through a full circle if you get it right, and a cable in the way will stop it at exactly the moment you were about to succeed.
Confirm the connection 2 min
Check the Brick icon: connected, or not.
Port A shows a motor. Note which kind.
Ports 1 and 2 both show a Touch Sensor.
Press the left button and check that tile 1 changes. Then the right, and tile 2. If they are crossed, swap the cables now.
A swapped pair here does not look like a bug. It looks like a ship that refuses to swing however hard you try — because every push is landing on the wrong side.
Make it move 10 min
Three stacks, six blocks. Look at the shape before you read the words: there are three separate hats, and a blank line between each. They are not one program that runs downwards — they are three programs that run together.
when program starts :: events hat
[A v] set speed to (60) % :: motors
[1 v] when [pressed v] :: events hat
[A v] run [clockwise v] for (120) [degrees v] :: motors
[2 v] when [pressed v] :: events hat
[A v] run [counterclockwise v] for (120) [degrees v] :: motors
The first stack runs once and sets the speed. The other two sit and wait — for ever — each for its own button.
How the Brick handles this:
When you press the green flag, the first stack runs its one block and finishes. The speed is now set.
The other two stacks do not run. They are armed — waiting for their sensors.
Press the left button and the second stack fires, on its own, without the first stack being involved at all.
Press the right button and the third stack fires.
Press left again and the second fires again. And again. A hat does not get used up.
Now use it. Start the ship swinging gently by hand, then tap the button that pushes it the way it is already going, each time it passes the bottom. Small pushes, in time. Watch the swing grow.
What success looks like: a swing that gets visibly bigger over eight or ten well-timed taps, and a ship that eventually makes it over the top. It will take several goes. That is the machine working, not you failing.
If the swing never grows, you are almost certainly pushing at the wrong moment rather than pushing too weakly. Try deliberately mistiming it — push against the movement for a few swings and watch the swing shrink. Once you can kill it on purpose, you know which moment is the right one.
Change it and test 8 min
One change at a time, and predict before each run. Count how many taps it takes to get over the top — that is your score, and lower is better.
Change both 120 values to 60. Smaller pushes. Predict whether you need more taps or fewer, and whether the ship is easier or harder to control.
Now 240. Bigger pushes. Most groups find this is worse, not better — a long push is still going when the ship has already turned round, so the end of it works against you.
Back to 120, and change the speed in the first stack to 100 %. A faster shove delivered in less time. Better or worse?
Change the [2] hat to [1], so both stacks wait on the same button. Predict what one press now does. Two stacks both grab port A at once and the result is a mess — this is the one-owner-per-motor rule, broken on purpose.
Put it back and add a fourth stack: when [center v] button [pressed v] with stop [all v] under it. Now you have an emergency stop that works whatever else is happening.
Step 5 is worth keeping for good. An emergency stop is the perfect job for its own stack, precisely because it must work regardless of where the rest of the program has got to. A single-column program can never offer that.
Anything that must work at any moment belongs in its own stack.
This is what you are building: the Crazy Pirate Ship.
Challenges & mission 27 min
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.
Challenge 1
Get it over the top, and count the cost. Using well-timed taps, bring the ship all the way round at least once. Then do it again and count how many pushes it took. Report your best count — and if you cannot get it round at all, report the biggest swing angle you reached and what is stopping you.
Challenge 2
Add an emergency stop on its own stack, using a Brick button, that halts the drive whatever else is happening. Then prove it works by triggering it in the middle of a push rather than between pushes. Explain in one sentence why this belongs in its own stack.
Challenge 3
Prove that timing beats force. Push at the wrong moment deliberately and bring a big swing down to almost nothing, then time how long that takes. Then do the opposite from rest. Report both, and state the rule you have demonstrated in one sentence.
Mission
Build the ride an operator could be handed, controls and all.
Your Crazy Pirate Ship must be drivable by somebody who has not practised: two clearly labelled controls, an emergency stop that always works, and something on the Brick that tells the operator what the machine is doing. They should be able to build a swing and bring it safely back down to rest.
Plan on paper before you build. Sketch every stack you are going to write and what starts it. Then check the one rule that will break you: does any motor have more than one stack trying to drive it?
Two questions when you demonstrate it. Why does your emergency stop work no matter where the rest of the program has got to? And what would happen if two of your stacks fired at the same instant — have you made that impossible, or just unlikely?
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.
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.