---
title: "Activity: Maze"
date: "2021-06-04"
categories: ["Activities", "All", "Simulator Activities"]
tags: ["Colour Sensors", "Branching", "Iteration", "Algorithm Design", "Ultrasonic", "IR", "Motors", "Beginner"]
excerpt: "Learn branching, iteration, algorithm design, and how to use the Rover’s motors, ultrasonic, colour, and IR sensors."
featuredImage: "/images/resources/maze.png"
---

Create a maze that students have to navigate their rover through. Use the rovers two IR sensors and ultrasonic sensor to detect walls and where they can drive. Use the rovers colour sensor to detect the finish.

####
  Relevant Coding Skills

    Branching

    Iteration

    Functions

    Variables

	--&gt;

    Algorithm Design

    Maths

####
   Relevant Rover Concepts

    Ultrasonic

    IR

    Colour

    Gyroscope

    Accelerometer

    Motors

    LEDs

	--&gt;

    Buzzer

 	--&gt;

![](https://images.squarespace-cdn.com/content/v1/60a43bf842d7b601064a8828/1622792353360-7EW09H59B15Z4MKI3BK1/maze.png)

            Activity Demonstration

### Setup

Construct mazes with any solid material that is tall enough for the rover IR & ultrasonic sensors to detect. We use boxes or wooden blocks to create our walls. The width of maze pathways will change how difficult the maze will be. For a challenging maze create pathways with 5-10cm allowance from each side of rover to the wall. The larger the width the easier.

To add complexity to mazes create additional tasks for students to complete in the maze. E.g. use coloured floor tiles or tape on your maze floor and task them to find all colour sections in the maze before they can finish or change speed at different colours.

### Here’s Our Approach

Solutions to maze challenges can vary in intricacy depending on rovers sensors utilized and maze complexity. Our basic approach only involves the ultrasonic sensor and the left IR sensor.

#### Stage 1

We start by creating a variable named wall which represents the distance (cm) from the side of our rover to the maze wall when the rover is placed in the middle of a maze path.

#### **Stage 2**

With an IF/ELSE IF/ELSE block we first check if the rover can move forward. If the ultrasonic sensor doesn't detect anything closer than our wall variable it will move forward. If it did not pass this check, it means there is a wall in the way and it now has to decide where to turn.

#### **Stage 3**

Our next case, the ELSE IF, will check if the left IR sensor detects a wall. If it doesn't, the way is clear & it will turn left. If it does detect a wall, it will go to the ELSE case and turn right. We then place the whole IF/ELSE IF/ELSE block in a while true loop so it will repeat this behaviour indefinitely.

![](https://images.squarespace-cdn.com/content/v1/60a43bf842d7b601064a8828/5f325f2d-9ac4-4896-8d87-633b6583eaf7/Screenshot+2023-10-31+083156.png)

Example Code

### Related Posts

          Resources

      [

![](https://images.squarespace-cdn.com/content/v1/60a43bf842d7b601064a8828/1639455538805-9NI7CPKR7IYG6D4RBKAN/high+quality+sumo.png)

  ](/resources/creating-a-sumo-unit)

	[All](/resources?category=All)

                [Creating A Sumo Unit For Your Digital Technologies Class](/resources/creating-a-sumo-unit)

	[All](/resources?category=All)

How to run a sumo unit in your digital technologies classroom.

                [Read More &#8594;](/resources/creating-a-sumo-unit)

	[All](/resources?category=All)

      [

![](https://images.squarespace-cdn.com/content/v1/60a43bf842d7b601064a8828/1637464845856-BBPD7GTIIHHOSJCFORWF/the+ultrasonic+sensor.png)

  ](/resources/ultrasonic-sensor)

	[All](/resources?category=All), [Guides](/resources?category=Guides)

                [The Ultrasonic Sensor](/resources/ultrasonic-sensor)

	[All](/resources?category=All), [Guides](/resources?category=Guides)

Learn all about the ultrasonic sensor!

                [Read More &#8594;](/resources/ultrasonic-sensor)

	[All](/resources?category=All), [Guides](/resources?category=Guides)

      [

![](https://images.squarespace-cdn.com/content/v1/60a43bf842d7b601064a8828/1625616494179-LZHZP5MUA0E0MQKEB7HC/cropped+image+4.png)

  ](/resources/year-7-digital-tech-at-st-peters)

	[All](/resources?category=All), [Customer Stories](/resources?category=Customer+Stories)

                [Case Study: Year 7 Digital Tech at St Peters Lutheran College](/resources/year-7-digital-tech-at-st-peters)

	[All](/resources?category=All), [Customer Stories](/resources?category=Customer+Stories)

See how Meg Foley at St Peters conducted a challenge for their Year 7s using Micromelon.

                [Read More &#8594;](/resources/year-7-digital-tech-at-st-peters)

	[All](/resources?category=All), [Customer Stories](/resources?category=Customer+Stories)
