Coding a LEGO® Maze

Coding a LEGO® Maze

Primary - Grade 3

Ayesha Akhlaq

Ayesha Akhlaq

About the author

Ayesha is a teacher and curriculum developer with extensive experience in STEM education. Having worked in different countries and serving on curriculum committees, she has gained valuable insights into the complexities of designing highly specialized, student-centred, and self-directed curricula. She is a strong proponent of utilizing technology to bridge the digital divide and advocates for using technology as a principal medium to deliver quality education to remote and rural communities.

Overview

In this lesson, students learn coding basics by building a rudimentary understanding of command codes, sequences, and loops. This lesson is a great opportunity for young learners to apply computational thinking in real-life contexts. By the end of the lesson, students will be able to solve problems using trial and error. This lesson is also a great starting point for an introduction to coding at a young age. 

Learning Objectives

  1. Learn how to apply reasoning and inquiry to building computational thinking skills 
  2. Foster creative thinking and problem-solving skills
  3. Introduce coding blocks and terms

Vocabulary

uujuq (UU-juq)
caribou stew
palaugaaq (pa-la-oo-GAAQ)
bannock, a biscuit bread
kamik (ka-MIK)
a skin boot
Amautalik (a-MAU-ta-lik)
an ogress from Inuit mythology who wanders the tundra in search of children. She has a basket made of driftwood on her back to carry away the children she finds wandering the land. She has long, unkempt hair and large, powerful hands. The basket on her back is very smelly, infested with bugs, and covered in slime to trap children inside

Source:  Putuguq and Kublu and the Attack of the Amautalik! by Roselynn Akulukjuk, Danny Christopher, Illustrated by Astrid Arijanto.


Materials

  • Code and Maze templates
  • Scissors
  • Pencils or markers to map out the path
  • LEGO® blocks and figurines (or other figurines of similar size)
  • Thermal laminator and laminating pouches (optional)
  • Paper cutter (optional)
  • Dice (optional)

Build a Story within a Game

For a great creative exercise, encourage students to write their own stories. Alternatively, read the following story to the students as a build-up to the activity.

Putugup and Kublu are brother and sister. One day, they were going to their grandparents’ house to enjoy some delicious uujuq with some yummy palaugaaq. Putugup lost his kamik in the snow and went looking for it. He wandered a little too far from the path and ran into an ogress who was wandering the tundra looking for the lost children. The ogress kidnapped Putugup and trapped him in a cave. The ogress blocked the entrance of the cave with an intricate maze so he couldn’t run away. The only way out of the maze was to find the exit using coding skills. 

When Putugup didn’t return after some time, Kublu went looking for her brother. She soon found the tracks of the ogress that led to the cave. She realized that her brother had been taken by the Amautalik. Kublu was very smart; she discovered that she had to solve the maze using code to rescue her brother. But since the cave is dark and gloomy, she will need your [the learner’s] help. Your mission is to use coding principles to help Kublu break Putugup out of the maze.  

Instructions

  • Cut out the coding blocks from the handouts provided
  • Set up the maze using the maze templates. It is recommended that students design their own mazes. Remind them to think backwards and keep a clear path to the exit. The maze shouldn’t be unsolvable

A finished maze might look like this:

Once the maze is set up, it is time to start the lesson.

Please note: It is for the teacher to decide what level of difficulty they want to introduce into the lesson based on the student’s age and their understanding of the “FOR” and “IF” statements.


Pre-K to JK: Basic Coding Statements

Using the story as a background, students apply coding principles to code their way out of the maze. Place the LEGO® figurines at the Start block. See how many moves in all directions can be made before running into obstructions. Count the steps until the figurines reach a blockage. Decide whether to turn right or left. Use one Go Forward block for each step. For example, if the figurine has to take four steps, use four Go Forward blocks. Use the Turn Left and Turn Right blocks to navigate the maze. Keep going until the figurines escape the maze.


JK to SK: Introduce the For Loop and End Statement 

At this point, students should be able to understand simple coding. If not, students with some knowledge of coding can start the activity from this point. Explain that loops are used when we want a process to repeat for a specified number of times, and to simplify the code. For example, instead of repeating the Go Forward block, we can use the FOR _____ steps block. In the blank space, fill in the number of steps to be taken, for example, four or five etc. Always place an END code to tell the LEGO® figurines to stop moving. END statements are an essential part of loops otherwise the program doesn’t know when to stop


Grades 1 to 3: Introduce If, Then, and Else If Statements

This level requires a lot of trial and error learning. It is helpful to give students real-life examples: If I eat all my veggies, Then I can have ice cream for dessert, or, If I don’t brush my teeth, Then I will get cavities; Else If I brush my teeth twice a day, Then I won’t have as many visits to the dentist. 

If, Then, and Else If statements are used for computational purposes to find the best possible solutions. At this stage, students should try to formulate the best way out of the maze by thinking in terms of If and Then

After setting the maze, ask the students to pick a number and roll the dice. For example, if students pick the number three,  and the dice roll is greater than three, the figurines can move forward. If the dice roll is less than three, the figurines move back a space. Keep repeating until the figurines reach the exit.   

Make sure the figurines don’t run into a dead end. If that happens, end the code and start over. 


Conclusion

The Government of Ontario’s Science and Technology curriculum has introduced Coding and Emerging Technologies expectations in the STEM Skills and Connections strand, starting from Grade 1. This lesson is one avenue for educators to introduce coding in a real-life context. After the activity, engage in a discussion about

  • The importance of coding literacy 
  • Practical applications of coding literacy
  • Technologies based on coding 
  • Impact of coding and emerging technologies on everyday life

Resources

This article originally appeared in the seventh issue of Root & STEM, Pinnguaq’s free print and online STEAM resource supporting educators in teaching digital skills