Maze Following Robot Logic

...determine whether or not it needs to turn to the right or the left.
...write the logic so that the robot can correctly navigate the maze.

It can't know whether it 'needs' to turn left or right, because it doesn't know which -way- is right.

It's not 'navigating' the maze as much as -solving- the maze.

I don't see anything in your description or code the names how the maze is solved?

Well, maze at least implies that the route is unknown. If this assignment is with a -known- path that you need to measure and navigate through, then the next paragraph is still pretty applicable.

Regardless.... Thinking as a robot, I'd make a mental map, an x/y array, that describes my travel options at each point I traverse and stop and look around. The maze probably has a fixed set of dimensions, the width of halls/doorways/rooms. Heck, maybe the dimensions aren't even know exactly, maybe they even vary - those are more cans of stinky worms to deal with.

From the starting point, measure what you see in each direction, and record it. Traverse a distance. Record again. From any given point you will see walls on one, two, or three sides. Three sides are a dead end. Open sides give the option for more mapping, and blocked sides tell you where you can't traverse.

Mostly I'm trying to give you an idea of how to 'traverse an unknown space' in software. There's probably a whole arcane math science of maze theory that's way over my head. Me, I'd ignore the theory and just hit it with the brute force of faster motors and sensors. LOL!! If you're -expected- to be dealing with this towards an 'optimal solution style' end, then that's why you were given the assignment and probably no one here will simply 'give you the answer.' :wink: Sensors, motors, arrays - we got those. :slight_smile: