Published in


Lego Maze Solving Tribot v1.0

Lego Solution Right-Wall-Follower-Robot — Episode #08

Let’s make a Maze Solving Robot? A robot traversing a labyrinth \o/

In this post, we will make Tribot v1.0 travels along the right wall through a maze. Boxes, piles of books, or large MDF wood work well for the maze walls. You could even build a maze out of Lego blocks!

We need to make Tribot v 1.0 respond correctly when it’s following the wall to its right then runs into a wall in front of it.

When the Tribot v 1.0 runs into the wall, the Touch Sensor will be pressed, at which point we can make the Tribot v 1.0 back up, make a quarter-turn to the left, and follow the wall it just ran into with the help of IR Sensor.

Here is our maze bravado ;)

The challenge is to always follow the right side of the wall. See an example of a maze gif solution.

We are using EV3’s IR and Touch Sensors. See this link for constructing your own robot.

And here is our video lab:

In robotics autonomy conventionally refers to the degree to which a robot is able to make its own decisions about which actions to take next. Thus a fully autonomous robot would be capable of carrying out its entire mission or function without human control or intervention.

However, at first, our robot is only a semi-autonomous. It really has a degree of autonomy but require some human supervision ;)

Our R_Follower_Robot v1 code must pass these 10 Maze Test; to test the code you need a wall with a corner and an opening, or you can use a full maze (which is a little more fun:)

Here is our first solution approach, graphically (thanks to my friend Pompermaier for the idea:)

Flowchart made with

And here is our EV3-G implementations:

Now here are some guidelines for you to use or adapt the previous code:


1º Step: if none of the sensors are activated, we will take care of the navigation in a range of 5–12 cm off-the-right-wall;

Code like this:

2º Step: If we hit one of the walls, stop, return and take the left direction;

Code like this:

3º Step: if we find a gap large enough, stop, advance a little, take the right 90º turn and advance a bit; If nothing happens, return navigation in the first Step and repeat the cycle again :b

Code like this:

Maybe you should shift some values on your benchwork. You can improve the program even more by adjusting the Steering parameter to control the sharpness of the Tribot v1.0's turns. But anyway, I think you’ve got the idea, right?

Here are some Tips'N Tricks:. Give Tribot v 1.0 enough room to turn when it gets to a corner;. Make use extensively of EV3’s Port View;. Slowing the Tribot v 1.0 down should help a lot;. If Tribot v 1.0 backs up or spins a little too far try few values for distance and rotations;. Before moving on to the next section of the program, retest the code from earlier to make sure it still works as expected;. When IR Sensor faces an opening, it will suddenly read a much greater distance than it did when following the wall; spent some time tinkering with this value; even the presence of your body is influential for this settings; mark the distance at a point of 90º's corner;. When you're done testing, you can use Sound Blocks for debugging; but be sure to test the program again after removing them to make sure that it still works;. When you are sure that the program fulfills its requirements, see how it works in other situations; For example, adjust the spacing of the walls (make corridors narrower or wider) to see how that influences the Tribot v 1.0’s behavior;. You can also try some curved or slanted walls to see how the Tribot v 1.0 responds; even though the program wasn't designed to handle these situations, it might work just fine; if not, think about how you might adjust the program to make it more versatile ;) 

All the code you can download from my Google Drive.

Well, that’s all!

I hope that was helpful;

I think this pretty much does it on our first attempt to solve this maze using LMS :)

Let me know if you guys have any specific questions or anything and I’ll try to address in the comments section below or at my youtube channel — click here;

Alright! see you later! bye.

Download All files For This Episode

Related Posts:

01º Lego Episode — Our Startup’s Journey — Invaders and Invasions?

02º Lego Episode — Timmyton Lego-Learning-By-Playing — L2BP Series

04º Lego Episode — Lego MotionsTribot v 1.0Seeing Your Creation Move — Move Steering Block

05º Lego Episode — Lego Motions Move Tribot Around — And Backward…Five Programs Files

06º Lego Episode — Lego SensorsTouch N Color — Two out of five human senses — Touch N Sight

07º Lego Episode — Lego Sensor LineFollower — Line Follower Tribot v1.0

08º Lego Episode — Maze Solving Robot v1 — Lego Solution Right-Wall-Follower-Robot

09° Lego Episode — Gettle_&_Sound_Bots — How gentle can a robot be? What is the audible range of the human ear? How deep can we dive?

10° Lego Episode — Data Logging — Data Collection and the EV3

11º Lego Episode — Binning the LineFollower Code — Binning: Arithmetic To Map Sensor Reading

12º Lego Episode — A Proportional LineFollower Robot — Advanced Math To Improve Your Robot’s Steering

13º LEGO Theory — Theory of Multitasking — A very Useful Programming Technique

14º LEGO formula — Normalizing Data — Converting Data to Use The Same Range

15º Lego Episode — PID — The Ultimate Line Follower — Algorithm for your EV3 PID Line Follower Robot

16° Lego Meets Pixy Episode — How to Connect Your Inexpensive Camera Module to Lego

18° Lego Episode — GEARS & WORMS — Geartrains & Worm & Clutch Gears

23° Lego Episode — Differential Explained — How Differential Works?

24° Lego Episode — PitBot — A Star Is Born — Working at The First Structure in Our Sparring Robot

25° Lego Episode — PitBot Is Agressive? Well, No Worries! — Making PitBot bite!

26° Lego Episode — Dancing Good w/ PitBot — All The Secret for Replicate This Awesome Robot

27 ° LEGO Episode — Sumo Arena is Ready! — Here is the playing arena for Arduino x Lego

28 ° LEGO Episode — Pick Pitbot Up! — Our Robot Are Leaving Body & Paint Shop

28 ° LEGO — B — Episode — Pitbot Battery & Sensor Setup — Preparing The infrastructure for running Arduino code

29 ° LEGO Episode — Bridging All Sensors Together — Pitbot — Collecting All Codes for the Final Act of Giving Behaviors to Robot

Credits & References

Pompermaier (Thank you, man!)

Connecting the IR sensor on the side of the Tribot v1.0



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


Hi, Guys o/ I am J3! I am just a hobby-dev, playing around with Python, Django, Lego, Arduino, Raspy, PIC, AI… Welcome! Join us!