Let's Make Robots!

Arduino Based Line Maze Solver

Solves a non-looped line maze

UPDATE : 5/24/2014: New video added ( with path shortening )

This was my 2nd robot. Back then, I had built it to solve a line maze but there wasn't a path shortening routine. And then, I came to know about Patrick Mccabe's maze solver. I had a look at his code, and edited it a bit just to get it working with the different sensors and motors used in my robot. So, credits for the code go to him.

The robot used plastic geared motors back then which is why it was quite difficult to abruptly change the direction of the motors or break their movement. As a result, I had to slow down the PWM value to an absolute minimum which resulted in an all-time slow robot but one that is super efficient in solving a non-looped line maze.

Sorry for the bad lights in the video, but the robot is running fine.

Future updates? Now that i have a couple of micro metal-geared motors, i might try using them for some more speed.


Hey there guys,

Here's a maze solver using arduino.



So, it basically traverses a non-looped maze structure made up using black tape on a white background. I made this one using an arduino uno clone and an L293D motor driver module. It's a bit shaky as the code is shaky and it needs revision.


It uses a Magician Chasis as a platform which comes with two acrylic plates, a pair of wheels, a pair of DC geared motors.


As you may have already known, it uses the left-hand-on-the-wall technique. So the order of preferences of turns is:

1) Make a left turn

2) Else move forward

3) Else make a right turn

4) Finally, if there's a dead end, make a 180 turn.

I am looking forward to implementing the path shortening routine in it soon.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.


I am using the same infrared sensor array (digital one) . But I was not able to optimize my code for line follower. Is it possible to post the code?


I should have mentioned it in the post above but since it is really popular, I didn't. The code is from patrick mccabe's maze solver. It is written for the pololu array sensor but can be edited to suit the tcrt5000 array. 

Also, which gear motors are you using? As the code contains tweaks to keep the robot as close to the line as possible , if you have plastic geared dc motors, it might be a bit unstable.



Dear Ashim,

I am also using magician chassis with plastic gear motors. When you are done with your code, I would like to compare with yours.


Did you check out the code that I mentioned? Check that out and I don't think you will have much problems. The only difference is that it has values for the analog sensor so you'll just need to replace them with the digital values. And you might want to add PWM too, just to lessen the speed of the plastic-geared motors.

I don't think I have the code right now as this robot was built a year ago. Please post your edited code in the forum and I and the others will be happy to help you out!