Skip to main content
Skip to main content

Sphero maze

Years 7-8

This lesson will explore how to program the Sphero using functions and show the benefits of decomposing the behaviour of the Sphero into functions, instead of writing line by line repeated behaviours.

This lesson idea was created by Claudia Szabo.



Prior Student Learning

Students have been exposed to Sphero using play-based learning, and are able to create simple algorithms using SPRK Lightning Lab. They are familiar with the coding aspects to enable basic control of a Sphero eg move in a square.

Learning hook

Discuss with students mazes:

  • Have you ever seen a garden maze?
  • What would be the best way to get out of/in a circular maze?
  • What about other mazes?

Ask students to devise an algorithm to get the Sphero to the center of this maze:

Sphero maze

Ask them how many instructions they would have to use to get the Sphero inside the center of this maze.

  • What if the maze was bigger, say, double in size?

Introduce the students to the concept of functions, showing how functions dramatically reduce the number of lines of code we have to write.

Identify the basic building blocks for getting to the centre of this maze:

  • How many building blocks can students identify?
  • What are the advantages/disadvantages of using each of them?

Introduce the concept of function parameters and how these are used within functions.

Learning map and outcomes

  • Students build their SPRK program without using functions
  • Students build their SPRK program using functions, identifying the parameters, and necessary building blocks
  • The key building block could be:
    • roll in a straight line for a while, corresponding to x meters (x is a parameter)
    • turn left
    • roll in a straight line for a while, corresponding to x meters (x is a parameter)
  • The algorithm would then see the repetition of this building block a number of times, with different parameter values.
  • This building block is called a function, say func_maze
  • Students write the algorithm using repeated calls to func_maze:
    • func_maze(5)
    • func_maze(4)
    • ...
  • Sphero algorithm with func_maze

Learning input

The teacher introduces the Sphero or Spheros to the class. Have the students discuss how Sphero can be sent instructions.

Allow time for discussion on Bluetooth and comparisons to Wireless. Discuss wireless, Bluetooth and connected networks.

Introduce or elaborate on visual programming languages and the importance of clear instructions (Algorithms) when controlling Sphero and setting tasks.

Discuss benefits of using functions.

Discuss challenges of using functions.

Learning construction

Students will work collaboratively to plan out their algorithm and write the program with and without functions.

Students will then work together to test and debug their programs.

Students can test their programs for different maze sizes.

As an extra challenge, students could devise mazes for other teams, and test and debug programs.

Another challenge can be asking students to write their program with the smallest number of blocks in the main part.

Learning demo

Once the lesson is complete, students will be able to move their Sphero to the center of the maze and show the repeated use of functions.

Learning reflection

Encourage students to reflect on the process:

  • What were the challenges when designing the function?
  • What were some of the advantages?
  • What other things do you need to consider when writing a program with functions?
  • What did you learn from creating this?
  • What were the fun moments?
  • Was it difficult to program the Sphero?
  • What are the advantages and disadvantages of using functions?
  • What was challenging about using functions?


  • Download entire lesson plan: PDF version.
  • Download entire lesson plan: Microsoft Word version.
  • Computer Science Education Research Group (CSER)
  • This lesson plan corresponds to professional learning in the following CSER Digital Technologies MOOCs:
    • F-6 Digital Technologies: Foundations
      • Unit 7: Algorithms and Programming
    • F-6 Digital Technologies: Extended
      • Unit 2: Algorithms & Programming Extended
    • Year 7-8 Next Steps
      • Unit 2 - Next Steps
      • Unit 3 – Problem definition and design
      • Unit 4 – Implementation and assessment

There are many Sphero apps now available to explore with your students on the iPad, more being added over time. Only a few are currently compatible with Sphero SPRK+. Here are some of the ones you might explore with your student: