Activity: Maze

BACK TO POSTS | OPEN PAGE AS PDF

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
Algorithm Design

Relevant Rover Concepts

Ultrasonic
IR
Colour
Motors
Activity Demonstration

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.

Example Code

 

Related Posts

Previous
Previous

Getting Started With The Micromelon Rover

Next
Next

Activity: Balance Bot