Today, you'll be teaching your students to act like programmers, learning how to give a robot a list of very specific commands to draw shapes on a grid.
Your students' job as programmers is to break down a big task, like drawing a square, into small, manageable steps. This process is called decomposition. If their robot makes a mistake, they'll need to figure out what went wrong and fix it—a skill known as debugging.
Start the lesson by asking your students, "If you had to tell a robot how to draw a simple shape—like a square—using only very small steps, what would you say?"
As they offer suggestions, the goal is to challenge them to be as specific as possible. Have them give you instructions for drawing a rectangle on the whiteboard.
Make it clear that you are acting as the robot and will only do exactly what you are told. Exaggerate any mistakes that happen when the instructions are too vague.
For example, if they say "Draw a line," you can draw a tiny, squiggly line. If they say "Draw another line," you can draw a long, diagonal line from a completely different spot on the board.
Prompt them to be more precise by asking questions like, "What kind of line? How long? In what direction?" This activity will highlight the importance of being very clear and specific in programming.
Today, your students will be acting as programmers, and you will be the "Art Bot." Explain that you are a very simple robot who can only understand a few specific commands to draw a picture on a grid. This time, your commands are based on the grid's directions, not your own. Your marker is your pen.
To begin, draw a simple 3x3 grid on the whiteboard. This is your world. Now, write the following commands on the board. Emphasize that these are the only words you, the Art Bot, understand.
MOVE_UP (1): Moves the pen up one square.
MOVE_DOWN (1): Moves the pen down one square.
MOVE_RIGHT (1): Moves the pen right one square.
MOVE_LEFT (1): Moves the pen left one square.
PEN_UP: Lifts the pen so it doesn't draw.
PEN_DOWN: Puts the pen down to draw.
Explain that their challenge is to combine these simple commands into a sequence, or program, to create a drawing.
Start by setting a challenge for the class: they'll work together to program you, the Art Bot, to draw a 3x3 square. Your starting position is the top-left corner of the grid, and your pen is already down.
Walk through the problem as a class, writing the sequence of commands on the board. Since the commands are now directional, the program will be a simple list of moves without any turns. As they work, emphasise the importance of breaking a big problem (drawing a square) into smaller, manageable steps. The final sequence should look like this:
MOVE_RIGHT (1)
MOVE_RIGHT (1)
MOVE_DOWN (1)
MOVE_DOWN (1)
MOVE_LEFT (1)
MOVE_LEFT (1)
MOVE_UP (1)
MOVE_UP (1)
The process you just used to draw the square—breaking down the big problem into smaller, manageable steps, like drawing one side at a time—is a key part of programming called decomposition. Programmers use decomposition to solve complex problems by tackling them one small piece at a time.
Ask your students:
"Why do you think breaking a problem down like this is a good idea?"
"Can you think of any other times you've used or could use decomposition?"
Guide the discussion toward real-world examples like building a LEGO set, completing a big art project, or even getting ready for school in the morning. This helps them understand that decomposition is a valuable skill they already use every day.