Lesson 3 · Your square mission
Big jobs.
Small, smart blocks.
Build a 4 × 4 grid. Give each useful job a name.
AI-generated voice · OpenAI CedarPress Read. The words being spoken will glow.
Start with the whole picture
What are we trying to make?
Sixteen little squares, arranged in four rows.
Hey, square builder!
Last time, you made Draw Square. You also used lots of moves and turns to draw more squares. That is a lot of steps to keep track of!
Today, we will give bigger jobs names, too. Our main program will be shorter and easier to follow. Then we can spend more time trying our ideas.
You already built Draw Square. Now your robot can use that tool to do a bigger job.
First, say the plan in ordinary words:
A big job becomes easier when we split it into smaller jobs.
That is divide and conquer.
“To make a grid, I need rows. To make a row, I need ______.”
Use something you already made
Your first tool: Draw Square
One name can stand for many steps.
When another block asks for Draw Square, this whole job runs.
Look inside Draw Square
A block’s definition explains how its job works. A call asks it to do the job.
Tap the block to open its definition above.
“I can ask for a square without listing all four sides.”
That is abstraction: use a helpful name for the details inside.
After the square is finished, where is the robot? Which way is it facing?
Check your prediction
New layer 1 · a small decision
Choose a direction. Then draw.
Draw Square with Direction uses your original Draw Square.
First think in words: Forward, Right, or Left. The input tells the robot which way to face before drawing.
| Direction | VEX number | What to do first |
|---|---|---|
| Forward | 0 | Keep facing the same way |
| Right | 1 | Turn right 90° |
| Left | 2 | Turn left 90° |
This VEX input uses a number. We give each direction a number, like a name tag. 1 means Right; it does not mean “turn 1 degree.”
Read the plan in words. Use the number checks shown underneath when building it in VEX.
An if asks a yes-or-no question. Its inside steps run only when the answer is yes.
Forward: both answers are no. Skip the turns, then draw the square. Forward means “keep facing,” even when the robot is facing right on the screen.
Predict what Left will do. Use its name tag, 2, in VEX. Which “if” question gets a yes?
Build this My Block in VEXcode
- Open Logic → My Blocks → Make a Block.
- Name it Draw Square with Direction. Add a number input named direction.
- Add two if blocks. Put an equals comparison in each question slot. Drag the direction input from the define block into each comparison, and compare it with 1 and 2.
- Put a right turn inside the first if, and a left turn inside the second.
- Put one call to Draw Square below both if blocks.
- Test calls with 0, 1 and 2, one at a time. Use 0 as the usual starting choice.
The input is a number in VEXcode. Forward, Right and Left are our meanings for those three numbers.
New layer 2 · combine smaller jobs
Teach the robot to draw a row.
Draw four squares. Then get ready for the next row.
Start at the row’s left corner, facing right. Each square uses Forward (name tag 0): keep facing right and draw.
In the real VEX call, enter 0 for Forward. “Get ready” is a plan label here; its real VEX steps are below, inside Draw a Row.
How do we get ready for the next row?
Keep the pen up. Go back to the left. Move down one square. Face right again.
Why 800? Four moves of 200 mm: 4 × 200 = 800.
Draw a Row knows how to use your smaller tools.
Do you see four squares? Does the robot finish at the next row’s left corner, facing right, with the pen up?
0 of 4 squares drawn.
Put the big picture at the top
Now the main program is tiny.
Face right. Ask for a row four times.
This plan starts with the Art Canvas robot facing up, as in a fresh reset. The first turn makes it face right.
The main program says what big jobs to do. Each block’s definition explains how its job works.
“I can understand the big plan, then look inside one job.”
That is top-down design.
Which block draws the four sides? Which block makes a row? Where do we decide how many rows?
A small next challenge
Predict what happens if the main repeat changes from 4 to 3. Which definition can stay exactly the same?
Later, try giving Draw a Row a “number of squares” input. Its return distance will need to change too.
0 of 4 rows · 0 of 16 squares.
Name a job. Build it. Test it. Use it in a bigger job.
Look back at your big idea
Same picture. Easier plan.
At the start, there were lots of steps to keep track of. What changed?
Before: follow many little jobs
Our main program mixed square calls with lots of moves and turns.
This shows the idea of the earlier plan.
Now: read the big plan
Face right. Ask for a row four times. Each row knows the smaller jobs.
The robot still does all the moves. We put the details inside jobs with useful names.
Now we do not have to follow every little move at once. We can read the big plan, then open one job when we need it.
Which plan is easier for you to follow? Why? If one square needs fixing, which block would you look inside?
A small reminder
Keep the big plan clear. Let each small job handle its details.
Your take-home project · a new picture
Can your robot draw stairs?
Use the same big idea to make a different drawing.
Make four stair steps. Start with the robot facing up on Art Canvas. Each step goes up a little, then right a little.
Choose a name for one small job and a name for the whole staircase. The bigger job should use the smaller one again.
Trace the picture with your finger. What part repeats? What should the robot do when you ask for one step?
- Build and test one step first.
- Use that job to make four steps.
- Explain your big plan without listing every move.
You can use paper to plan first. Keep your square project safe by saving the stairs as a separate VEX project.
Need a little help?
Try your idea first. Open one hint at a time. You do not need to open them all.
Hint 1 · Find the repeating part
Cover all but one step. Your finger goes up, then right. Could that little path be one job?
One possible name is Draw One Step. You can choose your own helpful name.
Hint 2 · Get ready to use it again
At the end of one step, the robot needs to face up again. Otherwise, the next step will go a different way.
Try one step twice. Does the second one carry on up the stairs?
Hint 3 · One possible small block
Start facing up. Try this inside Draw One Step:
It finishes one step farther up and right, facing up again.
Hint 4 · Put the small job to work
A bigger block called Draw Staircase can repeat Draw One Step four times. Your main program can just ask for Draw Staircase.
Now try three steps or five. Which number changes? Which small block can stay the same?
Show your drawing. Point to the small job and the big job. How did helpful names make your program easier to follow?
A new picture. Your own plan. The same smart idea.
Optional fun example · use a tool you already have
One square can become a flower.
You already know how to draw one square. What if we turn a little, then use it again?
Meet the Square Flower! Tap “Watch it bloom,” or start over and add one square at a time.
Can you spot one square inside the flower? What stays in the same place while the robot turns?
Use the Draw Square block you already made. Give the whole new job a name: Draw Square Flower.
Your main program can say just one big job:
One small tool. Use it again. Make something surprising.
8 of 8 squares.
Want to build your own?
Guess the plan first. Open a hint only when you need it.
Flower hint 1 · Reuse your square
Draw Square finishes at its starting corner, facing the same way. That makes it a useful tool to use again.
For this flower, that corner is the center of the picture.
Flower hint 2 · Add a little turn
Draw a square. Stay at the center. Turn right a little. Draw another square.
Try a 45° turn. That is half of the 90° corner turn you already know.
Flower hint 3 · One possible bigger block
Put this inside Draw Square Flower:
Eight little turns bring the robot all the way around. The four turns inside Draw Square still stay at 90°.
Show someone your flower. Which block makes one square? Which block makes the whole flower? What did you reuse?
A tiny main program. A big “look what I made!”
Keep your flower · try a new challenge
Can squares make it look round?
Here is your new target. Can you make this round-looking picture using Draw Square?
Keep your eight-square flower. Save a new copy of your project for this challenge.
Reuse the same Draw Square. Try a bigger job called Draw Round Pattern. You can start with the flower's plan.
What could happen if you draw more squares, but turn a smaller amount each time? Which two numbers in the flower's plan could you change?
Your main program can ask for the whole picture:
Each little shape is still a square. Together, the straight lines make a pattern that looks round.
Compare the pictures. Predict your own plan before opening a hint.
Need a nudge?
Try first. Open one hint at a time. The starting numbers are in the last hint.
Round hint 1 · Keep your small tool
Draw Square can stay the same. Keep its four corner turns at 90°.
Look at the bigger flower job. It chooses how many squares to draw and how far to turn between squares.
Round hint 2 · More squares, smaller turns
Try a smaller turn after each square. You will need more squares to keep going all the way around.
The small turn belongs after the Draw Square call. It is separate from the square's own corner turns.
Round hint 3 · Make one whole turn
One full turn is 360°. All the little turns between squares should add up to that.
If each little turn is 10°, how many will you need? You can count by tens: 10, 20, 30…
Round hint 4 · A starting pair to try
Try 36 squares with a 10° turn after each one. 36 × 10° = 360°.
Let Draw Square keep its 90° corners. Put the 10° turn after the square call, inside the big repeat.
Show your original flower and your new pattern. What did you change? Why did more squares and smaller turns make it look rounder?
The same small tool. A new big idea.