Introduction: Micro Mouse for Beginners (With Full Code)

About: A computer engineering student at Birzeit University.

Micro Mouse is a small robotic vehicle designed to navigate and solve a maze autonomously. The robot is programmed using microcontrollers like Arduino and equipped with sensors that help it detect and map its environment. The objective of the micro mouse competition is to find the shortest path from the starting point to the center of the maze.

The left-hand algorithm is a popular method used to navigate the maze. It involves keeping the left-hand side of the wall as a guide and always turning left at every intersection until reaching the center of the maze.

To program the micro mouse using Arduino, you will need to use a programming language like C++ and an Integrated Development Environment (IDE) like the Arduino IDE. You will also need to write a code that allows the robot to use the left-hand algorithm to navigate the maze.

Once the robot is programmed, it can be tested in a maze to see if it can navigate to the center using the left-hand algorithm. The robot's performance can be improved by tweaking its sensors, motors, and algorithms.

Overall, building and programming a micro mouse is a fun and challenging project that requires knowledge in electronics, programming, and robotics. With the right tools and techniques, anyone can build a micro mouse and compete in the micro mouse competition.

Supplies

1- Arduino Mega2560

2- Motor driver Hbridge

3- four Infrared sensors (Obstacle avoidance)

4- two Ultrasonic sensor

5- Jumbo wires

6- heat shrink

7- 2WD miniq robot car chassis

8- two DC motors with encoders

Step 1: Searching for Maze Solving Algorithms

The team started to search for the best algorithm to be used, we found the flood fill algorithm that needs a localization technique. thus, we decided to use the left-hand algorithm for its simplicity as a soft start for solving the problem.

Step 2: Coding the Algorithm

Coding the left-hand algorithm is an important step in building a micro mouse robot. The left-hand algorithm is a simple and effective method for navigating a maze, and it involves keeping the left-hand side of the wall as a guide and always turning left at every intersection until reaching the center of the maze.

Here are the steps to code the left-hand algorithm for a micro mouse robot:

  1. Define variables: Start by defining variables for the robot's sensors, motors, and direction. You will need to define variables for each of the sensors and motors that you are using in your robot.
  2. Set up the sensors: Initialize the sensors and set up the pins for the ultrasonic and IR sensors. This involves writing the code to read the sensor data and store it in the variables you defined earlier.
  3. Set up the motors: Initialize the motors and set up the pins for the motor driver. This involves writing the code to control the direction and speed of the motors.
  4. Define the left-hand algorithm: Write the code for the left-hand algorithm. This involves using conditional statements to check for walls and intersections and deciding which direction to turn based on the left-hand rule.
  5. Test the algorithm: Once you have written the code for the left-hand algorithm, test it in a simple maze to see if it can navigate to the center of the maze. You may need to tweak the algorithm and adjust the sensors and motors to improve the robot's performance.
  6. Add more functionality: Once the basic left-hand algorithm is working, you can add more functionality to the robot. For example, you can incorporate more sensors, add a line-following capability, or implement a faster pathfinding algorithm.

For code, see the GitHub repository at the end of this tutorial.

Step 3: Simulating the Code Using the Mms Simulator

After coding the algorithm using c++, it needs to be tested using a simulator, and here we used the mms simulator.

for using the simulator and downloading it, follow the link:

mackorone/mms-c: Write a Micromouse maze-solving algorithm in C (github.com)

Step 4: Preparing the Maze

As the problem specification file mention, the robot should suite a maze constructed form 16*16 cell, each cell of width 18 cm and with walls of 5cm high, in addition to more details specified in the problem document. For that, we created a 4*4 maze to help us adjust our robot and test it before the real evaluation.

Step 5: Getting the Required Equipements

We got all the required tools to help us start building and testing our robot.

Step 6: Testing and Adjusting Sensors

Before building the robot, we adjusted the IR and ultrasonic sensors for the distances we want, we also prepared out batteries by charging them to get the best performance when running the robot.

Step 7: Building the Robot

After testing each component alone, we started to build the robot, we used 4 IR sensors, two for the front to detect the best angle and one for each side to detect side walls. we also used two ultrasonic sensors one on each side to help the robot adjust its location while running in the maze.

for the structure of the robot, we put the Arduino and the batteries on the top to provide the best balance in the robot weight, while the rest of the components are put down on the first layer so the sensors can sense the 5 cm walls.

Step 8: Testing How Our Robot Turn Left and Right

Before uploading the code, we first tested how to make the robot rotate on the same cell.

(1) Turning left and right - YouTube

Step 9: Uploading the Code to the Robot

Step 10: Testing the Robot on Our Maze

Step 11: Additional Details

Here you can find more details about our robot:

Trello Link: Maze Solver | Trello

YouTube channel: (1) Interfacing project - YouTube

GitHub Link: ahmad-m-abbas/Interfacing-Techniques-Project (github.com)

Google Drive Link: Drive link