The Drawing Machine. An arm holds a pen and swings it across the paper. A second motor moves the paper under the pen. Press the Touch Sensor and it draws by itself. Nobody holds the pen.
This machine makes something you can keep. When it stops, you have a paper with a pattern on it. The pattern shows if your program was right.
Level 2 keeps asking one question:does it do the same thing every time? A robot that works once is just lucky. Here the paper shows you. The second drawing should look just like the first.
In the real world 5 min
Where you have seen it
Before big printers, there were pen plotters. A real pen sat in a holder. Two motors pulled it across real paper. One moved the pen, and one moved the paper. Engineers drew plans for buildings on them. Schools drew graphs.
A pen plotter drawing a chart. The pen slides along the clear rail. The paper moves the other way. Photo: Elke Wetzig / Wikimedia Commons (CC BY-SA 4.0).
Why it is built that way
A pen draws a line the way it is pulled. One motor pulls one way. That gives you one straight line. You could draw a dash, and nothing else.
So a plotter uses two motors that pull in different ways, like the corner of a square. The shape comes from both moving at the same time. Move the pen right while the paper moves up. The pen draws a slanted line. Change how fast each one goes, and the slant gets steeper or flatter. Every curve a plotter draws comes from two motors running at different speeds.
What would go wrong without it
Make them take turns, and the machine still works. It just draws nothing useful. Move the pen all the way across. Stop. Move the paper. Move the pen back. You get lines side by side, with gaps between them. It looks like a ladder, not a drawing.
The drawing does not come from one motor. It comes from the two of them running together.
The main concept — one stack is a queue 6 min
Blocks in a stack take turns. Block two does not start until block one is done. The EV3 always does this. Most of the time, that helps. On the Crazy Pirate Ship in Lesson 36, you split a program into stacks. Today two stacks start at the same moment.
when program starts :: events hat
[A v] run for (4) [rotations v] at (40) % speed :: motors
[D v] run for (4) [rotations v] at (40) % speed :: motors
One stack. The pen goes all the way across. Only then does the paper move. Two moves, one after the other.
Read that program and picture the paper. The arm goes across and draws a line. It stops. The paper moves. Nothing draws while the paper moves, because the pen is still. You get a line, then a gap.
Now here are the same two blocks in two stacks:
when program starts :: events hat
[A v] run for (4) [rotations v] at (40) % speed :: motors
when program starts :: events hat
[D v] run for (4) [rotations v] at (40) % speed :: motors
Two stacks, two hats. Both start when the program starts. Neither one waits for the other.
Same blocks. Same speeds. But a very different drawing! Now the paper moves while the pen moves. So the pen draws a slanted line, not a straight one.
Blocks in one stack wait for each other. Separate stacks do not. Do you want two things to happen at once? Then put them in two stacks.
You can have as many stacks as you like. They all start when you press Play. This is how a robot can walk and talk at the same time. It is also how a robot can watch a sensor while it does something else.
▶Doing two things at onceAll about stacks that run together. When to use them, and the one thing that goes wrong. Open it if the two-hats idea 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.
One rule to remember. Two stacks must never drive the same motor. Both will send it orders. The motor obeys the last one it got. So it does something different each run. That is the “works once” problem Level 2 is here to fix. One motor, one stack.
Say this back before moving on: “Two things at the same time means two stacks.”
What’s in this build 4 min
Part
What it is doing here
EV3 Intelligent Brick
Runs both stacks at the same time. It is not taking quick turns. To you, they are both just running.
Large Motor — the pen arm
Swings the pen across the paper. You see this move the most. It decides how wide the drawing is.
Second motor — the paper feed
Moves the paper under the pen. It is almost always slower than the arm. It only has to move the paper a little for the pen to reach a new place.
Touch Sensor
The start button. The program waits for it. So the drawing starts when the paper is straight and your hands are out of the way. It does not start the moment you press Play.
The pen (not electronic)
It must press hard enough to draw, but not so hard that it cannot slide. In this lesson, half the problems come from the pen, not the code.
Check the pen before you check anything else
Take the cap off! Every class loses ten minutes to a pen with its cap on.
Push the arm across by hand. Does the pen draw a line all the way? Or does it fade in the middle? If it fades, the paper is not flat or the arm is not level.
Lift the arm and let it down. It should rest on the paper by its own weight. It should not be pushed hard into it.
Push the paper feed by hand. The paper should move smoothly. It should not lift or fold.
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
Pen-arm motor
A
A and D are for motors that do a job, not motors that drive wheels. The arm does a job.
Paper-feed motor
D
This is at the other end of the Brick. So the two cables do not crowd one corner and tangle over the paper.
Touch Sensor
1
Touch is always port 1 in this course. Learn one habit and it works in every lesson.
Check your own build now. Your motors may not be where the table says:
Find the motor joined to the pen arm. Look at its port. Use that port in the first stack.
Find the motor joined to the paper feed. That one goes in the second stack.
Are they in A and D? Then use the program below as it is. If not, change the two port menus and nothing else.
Keep the cables away from the paper. A cable on the paper will get drawn on. It will also pull the paper out of line.
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 today. The Drawing Machine stays on the table, so a cable is no problem. And a cable never loses the connection halfway through a drawing.
Confirm the connection 2 min
Check the Brick icon: connected, or not.
You should see two motor tiles and one sensor tile. Is a motor tile missing? Then the cable is loose. The program will still run, but half your machine will sit still.
Turn the pen arm by hand and watch which tile changes. Now you know the arm’s port for sure. You do not need to follow the cable.
Press the Touch Sensor and watch its tile change. If it does not change, your program will wait for ever. It will look broken.
Change it and test 8 min
Use new paper each time. Make one change per run. Guess the shape before you press Play. Keep the sheets. Lay them side by side to see what each number does.
Change the paper feed to 30%. The two speeds are now closer. Will the slope get steeper or flatter? Guess before you run it.
Change the paper feed to 0%. Guess what you get. This is the same drawing as a one-stack program. It is good to see it on paper.
Put the feed back to 15%. Change the arm to 20%. Both are slow now. Is the shape different, or only the time it took?
Make the arm speed negative (−40). It swings the other way. Which corner does the drawing start from now?
Give the paper-feed stack a wait (2) seconds before its motor block. The arm starts alone. The paper joins in later. Look closely at where the line bends.
Step 5 is the fun one. The two stacks are not doing the same thing at the same time now. Each one does its own thing, at its own time. That is the real power of two stacks. You can see it in the bend in the line.
Two stacks do not have to match. They can have different speeds, different directions, and different start times.
This is what you are building: the EV3 Drawing Machine.
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.
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.
Make it move 10 min
Two stacks, side by side in the same project. Build the first one. Then drag a second "when program starts" hat to an empty part of the screen. Build the other stack under it.
when program starts :: events hat
[1 v] wait until [pressed v] :: sensors
[A v] run for (6) [rotations v] at (40) % speed :: motors
when program starts :: events hat
[1 v] wait until [pressed v] :: sensors
[D v] run for (6) [rotations v] at (15) % speed :: motors
Both stacks wait for the same press. Then both run. The arm goes at 40 and the paper at 15. The speeds are different on purpose.
Here is what the Brick does, in order:
You press Play. Both hats start at once. Neither stack goes first. "First" and "second" only tell you where they sit on your screen.
Both stacks reach wait until pressed and stop there. The machine looks dead. It is not. It is waiting, twice.
You press the Touch Sensor. Both waits end together. That is because both were watching the same sensor.
The arm runs 6 rotations at 40%. At the same time, the paper runs 6 rotations at 15%. The paper is slower, so it moves less far in the same time. The pen draws a long, gentle slope, not a straight line.
What success looks like: one long line on the paper. It does not run alongside the edge of the paper. Does your line run dead straight along the paper? Then one motor is not turning. Go back to section 8.
Does only one motor move? Then you most likely built the second stack under the first one, not beside it. Blocks joined in one column are one stack, however long it is. Drag the second hat well away. Check you can see a gap.
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
Draw a line that one motor alone could not draw. A line that slopes across the page proves both motors ran at the same time. A line that runs along the edge of the paper proves one motor was not running. Keep the sheet. Write the two speeds on the back.
Fullscreen it while you build — you can pause and scrub with the player's own controls.
Challenge 2
Draw a shape with a corner in it. The pen must change direction part of the way through. You must not touch anything. So one stack has to change what it does. The other stack keeps going. Say which stack made the corner.
Challenge 3
Draw the same picture twice and make the two sheets match. Run it. Take the paper off. Put a new sheet on in the same place. Run it again. Hold the two sheets up to the light together. Anything that does not line up is something you have not controlled yet. Find it and say what it was.
Extra challenge
Design a machine that signs its own name.
Your drawing machine must draw the same mark every time it runs. It could be a letter, a symbol or your initials. Anyone should be able to look at two drawings and know they came from one machine.
Plan on paper first. Work out which motor does what in each part of the mark. Where must the two stacks start together? Where must one stack wait? What must be true before the pen even touches the paper?
Then prove it. Draw the mark five times on five sheets. Do not change anything between runs. Lay all five side by side.
Answer two questions when you show it. Which drawing is the odd one out? What made it different: the machine, the paper, the pen or the program? Also, think of another group using your machine to copy your mark just right. What would you need to tell them that is not already in the program?