Arduino | Maze Solving Robot (MicroMouse) \ Wall Following Robot

64,647

46

75

Introduction: Arduino | Maze Solving Robot (MicroMouse) \ Wall Following Robot

Welcome I'm Isaac and this is my first robot "Striker v1.0".
This Robot was designed to solve a simple Maze.
In the competition we had two mazes and the robot was able to identify them.
Any other changes in the maze may require a change in the code and the design but it's all easy to do.

Step 1: Parts

First Of all You need to know what are you dealing with.

Robots = Electricity + Hardware + Software

1- Electricity: batteries have many specs you should only know how much Current and Voltage you need.

2- Hardware: " Body, Motor, Motor Driver, Sensors, Wires and The Controller " you should only get the important parts that do the task, no need to get a fancy expensive Controller for a simple task.


3- Software: The code is all about logic. Once you understand how the controller works it will become easy for you to choose the functions and to make the code more simple. The code language is determined by the controller type.


Part List:

  1. Arduino UNO
  2. 12v DC motors (x2)
  3. Wheels (x2)
  4. Motor Driver (L298N)
  5. Distance Sensor (Ultra Sonic)
  6. Wires
  7. 12v Battery (1000 mAh)

Tools List:

  1. Battery Charger
  2. Acrylic sheet
  3. Soldering Iron
  4. Wire cutter
  5. Nylon Zip Wrap

For Extra fun you can use LEDs to light it up but it's not very important.

Step 2: Body Design

The main Idea was to stack the parts above the body and use the Nylon Zip Wrap stabilize the Arduino and Wires will stabilize the rest thanks to their lightweight.

I used CorelDRAW To design the body And I made extra holes in case of any future changes.

I went to a local workshop to use the laser cutter then I started to build it all together.
Later On, I made some changes cuz the Motors were longer than I expected.

I want to say that your robot does not have to be built in the same manner as mine.

PDF file and The CorelDRAW File are attached.

If you are not able to laser cut the design, do not worry. As long as you have an Arduino, the same sensors, and motors then you should be able to get my code to work on your robot with minor changes.

Step 3: Implementation (building)

The design made it easy to fix sensors on the body.

Step 4: Wiring

Here is a schematic diagram of the robot. these connections are related to the code.
You can change the connections but make sure to change the code with it.

The parts.

Sensors

I would like to explain "The Ultrasonic sensor"

An Ultrasonic sensor is a device that can measure the distance to an object by using sound waves. It measures distance by sending out a sound wave at a specific frequency and listening for that sound wave to bounce back. By recording the elapsed time between the sound wave being generated and the sound wave bouncing back.This seems similar to the working of Sonar and Radar.

The connection of the Ultrasonic Sensor to the Arduino:

  1. GND pin is connected to the Ground.
  2. VCC pin is connected to the Positive (5v).
  3. Echo pin is connected to the Arduino. (choose any pin and match it to the code)
  4. TRIG pin is connected to the Arduino. (choose any pin and match it to the code)

You will make a common Ground and connect all GNDs to it ( sensors, Arduino, Driver ) all grounds should be connected.

For Vcc Pins also connect the 3 Sensors to a 5v Pin

( you can connect them to the Arduino Or the Driver I recommend the Driver)

Note: Don't connect the Sensors to a voltage higher than 5v or it will be damaged.

--------------------------------------------------------------------------------------------------

Motor Driver

The L298N H-bridge: it's an IC that can allows you to control the speed and direction of two DC motors, or control one bipolar stepper motor with ease.
The L298N H-bridge driver can be used with motors that have a voltage of between 5 and 35V DC.

There is also an on-board 5v regulator, so if your supply voltage is up to 12v you can also source 5v from the board.

Consider the image – match the numbers against the list below the image:

  1. DC motor 1 “+”
  2. DC motor 1 “-”
  3. 12v jumper – remove this if using a supply voltage greater than 12v DC. This enables the on-board 5v regulator
  4. Connect your motor supply voltage here, maximum of 35v DC.
  5. GND
  6. 5v output if 12v jumper in place
  7. DC motor 1 enable jumper.Remove the jumper and Connect to PWM output for DC motor speed control.
  8. IN1 Direction Control
  9. IN2 Direction Control
  10. IN3 Direction Control
  11. IN4 Direction Control
  12. DC motor 2 enable jumper. Remove the jumper and Connect to PWM output for DC motor speed control
  13. DC motor 2 “+”
  14. DC motor 2 “-”

Note: This Driver allows 1A per channel, draining more current will damage the IC.

------------------------------------------------------------------------------------------------------

Battery

I used 12v Battery with 1000 mAh.

The table Above shows how the voltage drops when the battery discharge.
you should keep it in mind and you have to recharge the battery constantly.

Discharge time is basically the Ah or mAh rating divided by the current.

So for a 1000mAh battery with a load that draws 300mA you have:

1000/300 = 3.3 hours

If you drain more current the time will decrease and so on.

Note: Make sure that you don't exceed the Battery Discharge Current or it will be damaged.

Also again make a common Ground and connect all GNDs to it ( sensors, Arduino, Driver ) all grounds should be connected.

Step 5: Coding

I made these into functions and I had fun coding this robot.

The main idea is to avoid hitting walls and to get out of the maze.
we had 2 simple mazes and I had to keep that in mind cuz they were different.

The blue maze uses right wall following algorithm.

The red maze uses left wall following algorithm.

The photo above shows the way out in both mazes.

Code flow:

  1. defining the pins
  2. defining output and input pins
  3. check sensors' readings
  4. use sensors' reading to define walls
  5. check first route (if it was left then follow the left wall, if it's right follow the right wall)
  6. Use PID to avoid hitting the walls and to control motors' speed

You can use this code but change the pins and the constant numbers to get the best results.

Follow This Link for the code.

https://create.arduino.cc/editor/is7aq_shs/391be92...

Follow This Link for the library and the Arduino Code File.

https://github.com/Is7aQ/Maze-Solving-Robot

Step 6: Have Fun

Make sure to have fun :D

This is all for fun don't panic if it's not working or if there is any thing wrong. track the error and don't give up.

Thanks for reading and I hope it helped.


Contact:

E-mail: Is7aq.s7s@gmail.com

Arduino Contest 2017

Participated in the
Arduino Contest 2017

3 People Made This Project!

Recommendations

  • Battery Powered Contest

    Battery Powered Contest
  • Plywood Challenge

    Plywood Challenge
  • Plastic Contest

    Plastic Contest

75 Discussions

0
kavithadarshaka1
kavithadarshaka1

Question 2 months ago

What is 'first_turn = false; ' mean? Thank you.

0
Isaac Hossam El-Din
Isaac Hossam El-Din

Answer 5 weeks ago

it means that the robot didn't detect the first turn and will use the kickoff PID instead of wall following algorithms.

0
MüminElcin
MüminElcin

7 months ago

what is the change I need to make in my maze path width 20 cm code. thank you.

0
Isaac Hossam El-Din
Isaac Hossam El-Din

Reply 7 months ago

Hi,
If I got your question right, you'll need to change wall thresholds and try with different speeds.

0
MüminElcin
MüminElcin

Reply 7 months ago

what are the dimensions of the robot you made. let me compare

0
Isaac Hossam El-Din
Isaac Hossam El-Din

Reply 7 months ago

Hi,
as for the body itself the PDF file is ready to print which means it's the exact dimensions which is 10 cm x 15.5 cm .. however, some parts like the motors are of the body which increases the width of the robot .. also after the build I kinda broke the tail part so the length was shorter anyway it's the smallest I can get.

0
MüminElcin
MüminElcin

Reply 7 months ago

thank you

0
MohammedA741
MohammedA741

1 year ago

how How you built the pid?

0
nguyen01266
nguyen01266

1 year ago

I'm making a robot with a labyrinth measuring 120 cm x 210 cm
Wall covering is 20 cm high, the width of each wall is 30 cm, the vehicle size is 18 x 18 cm
I have seen how to connect hardware but I don't use leds, can you show me and fix the code for me?

unnamed.png
0
Isaac Hossam El-Din
Isaac Hossam El-Din

Reply 1 year ago

Hi,
Simply don't connect any leds, the code will work normally without them .. however, the wall following algorithm isn't designed for the maze you shared in the picture .. it will take longer paths and may not work perfectly for your case (check the maze I shared) and I didn't develop a code that works with the maze you shared .. you may need to check A* algorithm or other memory dependent algorithms ..

0
nhatquang25082000
nhatquang25082000

Reply 1 year ago

Can you help me write a code for this yard, my wall is 30cm wide 18cm wide, 210cm long 120cm wide. Can you please test the code for me? bro

0
HarikiranI
HarikiranI

1 year ago

does it recognize the shortest path

0
Isaac Hossam El-Din
Isaac Hossam El-Din

Reply 1 year ago

Hi,
Nope it doesn't, it just follows a wall ..

0
panda27231
panda27231

Question 1 year ago

How can i modify the code

0
Isaac Hossam El-Din
Isaac Hossam El-Din

Answer 1 year ago

Hi,

You can use Arduino IDE software .. it's simple and easy ..

0
panda27231
panda27231

1 year ago on Step 5

Hello sir can you please make me a diagram how to connect the motor driver to the arduino coz please
This is for my project

0
panda27231
panda27231

Reply 1 year ago

Sir how to lessen the speed

0
Isaac Hossam El-Din
Isaac Hossam El-Din

Reply 1 year ago

Hi,
Please check Step 4, it's all about wiring .. however, I'm using L298N Motor Driver so if you're using a different driver please check it's data sheet before connecting it .. as some require different codes ..

0
panda27231
panda27231

1 year ago

How to fix the diagnostic error it says

Used of undeclared identifier