- Mathematics
- Class 4
- Project 5
5Code the Robot Cleaner: Unplugged Programming on a Grid
One child is the "robot" on a floor grid; teammates write a short program using arrows and turn commands to guide it to collect rubbish, then find the shortest program and fix bugs.
- Class and age
- Class 4 · 9–10
- Activity type
- Group
- Time needed
- 60 minutes
- Difficulty
- Medium
- Estimated budget
- ৳0–৳30
Mathematical concepts
- Position and direction on a grid
- Quarter turns (left and right turns are right angles)
- Sequences of instructions (algorithms)
- Repetition: 'repeat 3 times'
- Counting steps and comparing route lengths
Learning objectives
- Write a precise sequence of moves to reach a target.
- Use quarter turns correctly from the robot's point of view.
- Find and fix errors (debugging).
- Shorten a program using repeats.
Real-life connection
Delivery riders follow route instructions, Google Maps gives turn-by-turn directions, and factory robots and automatic vacuum cleaners follow programs. Every app on a phone is a long list of exact instructions.
Materials required
- Chalk or masking tape to make a 6 × 6 floor grid (squares about 40 cm)
- 5 paper 'rubbish' cards and a 'dustbin' card
- Command cards: ↑ (forward 1), ↰ (turn left), ↱ (turn right), 'repeat ×'
- Paper and pencil for writing programs
Step-by-step instructions
- Curiosity starter: the teacher acts as a robot and follows a child's instructions literally ('Go to the door': the robot does not know what 'go' means!). 'What exact words does a robot need?'
- Agree the language: only three commands: ↑ forward one square, ↰ turn left on the spot, ↱ turn right on the spot. Turns do not move the robot.
- Set up the grid: mark a start square with the robot facing 'north' (towards the board). Place the dustbin and rubbish cards.
- First mission: teams write a program on paper to move the robot to one rubbish card. The robot child follows it exactly, without helping.
- Debugging: if the robot ends in the wrong place, the team finds the first wrong command and fixes it. Praise good debugging.
- Bigger mission: collect three rubbish cards and finish at the dustbin.
- Count and compare: count the commands in each team's program. Who has the shortest program that works?
- Repeat command: introduce 'repeat 3 × (↑)' instead of ↑ ↑ ↑. Rewrite programs to be shorter.
- Swap roles so every child is a robot once and a programmer several times.
- Paper version: solve a mission on a 6 × 6 paper grid with a pencil 'robot'.
- Reflection: 'Why must instructions be exact? What was your best bug?'
Mathematical explanation
An algorithm is a finite list of exact steps that solves a problem. On a grid, a robot's position changes only with 'forward' moves, while 'turn' commands change its direction by a quarter turn (a right angle, 90°). Left and right depend on which way the robot is facing, which trains spatial reasoning. Using 'repeat' replaces many identical steps with one instruction, the same idea as multiplication replacing repeated addition. Finding the shortest working program is an early taste of optimisation in computer science.
Expected project output
- Written programs for at least three missions
- A 'bug report': the error found and how it was fixed
- A shortened program using repeat
- A solved paper-grid mission
Skills developed
Computational thinking, spatial reasoning, precise communication, debugging, teamwork.
Assessment criteria
- Writes a program that works on the first or second try.
- Uses turns correctly from the robot's direction.
- Finds and fixes a bug and explains it.
- Shortens a program using repeat.
Extension challenge
Write a program that makes the robot walk around a 3 × 3 square and return to the start facing the same way. How few commands can you use? What if the square is 4 × 4? Try the free Scratch website if a computer is available.
Safety and inclusion
Clear the floor area of bags and furniture edges. The 'robot' walks slowly. A child who uses a wheelchair can be the robot with a partner, or the programs can be run with a toy on a desk grid.