Files
micromelon-website/content/resources/maze.mdx
Tim Hadwen 99534e779a Consistent hero layouts, activity page redesign, new content, and YouTube embeds
- Product pages (Code Editor, Robot Simulator): text-left/image-right hero layout
- Related resources capped at 3 items on all product pages
- Making Music activities renamed to I, II, III
- New Maze I/II/III and Sumo I/II/III difficulty-graded activities
- YouTube demo videos restored on 12 activity pages from old site
- Activity pages: two-column hero with coding skills & rover concepts tags
- Blog/news pages: same two-column hero layout with date
- Resource type extended with codingSkills, roverConcepts, tags fields
- Removed raw "Relevant Coding Skills/Rover Concepts" text from activity MDX

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 23:56:05 +10:00

47 lines
2.2 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Activity: Maze I"
date: "2021-06-04"
categories: ["Activities", "All", "Simulator Activities"]
tags: ["Colour Sensors", "Branching", "Iteration", "Algorithm Design", "Ultrasonic", "IR", "Motors", "Beginner"]
excerpt: "Learn the basics of maze solving using the ultrasonic and IR sensors to detect walls and navigate simple paths."
featuredImage: "/images/resources/maze.png"
---
Navigate your rover through a maze using the ultrasonic sensor to detect walls ahead and the IR sensor to check for walls to the side. This beginner approach introduces the fundamentals of maze solving with simple branching logic.
![](/images/content/1cf38b-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. For this first level, keep pathways wide with at least 15cm clearance on each side of the rover to make it easier for students to get started.
### Heres Our Approach
This 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 doesnt 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 doesnt, 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.
![](/images/content/82838c-screenshot-2023-10-31-083156.png)
Example Code
### Up Next
Ready for a harder maze? In Maze II youll use both IR sensors and the ultrasonic sensor together to handle more complex maze layouts.
[Activity: Maze II](/resources/maze-ii)
[Activity: Maze III](/resources/maze-iii)