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

16,529

25

30

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 Lithium-ion Battery (1000 mAh)

Tools List:

  1. Battery Charger
  2. Acrylic sheet ( Check what's available in your local store)
  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 conestant 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

Share

Recommendations

  • Make it Glow Contest 2018

    Make it Glow Contest 2018
  • Plastics Contest

    Plastics Contest
  • Optics Contest

    Optics Contest

30 Discussions

0
None
khaled_77

16 hours ago on Step 6

Arduino: 1.8.5 (Windows 10), Board: "Arduino/Genuino Uno"
C:\Users\khaled\Downloads\Striker_v2_copy3\Striker_v2_copy3\Striker_v2_copy3.ino:5:21: fatal error: NewPing.h: No such file or directory
#include <NewPing.h>
^
compilation terminated.
exit status 1
Error compiling for board Arduino/Genuino Uno.



why this message shows to me while verifying ????????????

0
None
Ayomipo

4 days ago

Can the Robot solve any type of maze?

0
None

increase Base Speed .. also change the wall threshold that triggers the turn function .. calculate the best wall threshold and try it to see if it works ..

0
None

You have to change the wall threshold that triggers the turn function .. calculate the best wall threshold and try it to see if it works ..

0
None

You should increase the Base speed and try which base speed works better.

0
None
KacperT2

8 days ago

Hello, great project for begginers. Could you give me a link to the motors that you have used in your project? If these are not available to buy, could you give me an example of cheap motors with encoders that i could use in this project?

0
None
DylanT59

Question 6 weeks ago

Hello,

I would like to know how will the robot react when encountering a dead end based on your coding? I have tested yr coding and I found out that the robot is unable to stop when sensors readings are greater than 100cm. Can you advice on how to solve this problem?

Thanks

1 more answer
0
None
Isaac Hossam El-DinDylanT59

Answer 4 weeks ago

Hello,
It totally avoids dead ends by following the right path .. So it has no reactions for such cases ..

for the robot to stop it has to:
1- Trigger one of the wall following algorithms ..
2- Sensors MUST read more than 100 cm or 0 ..

And if you have any other queries please contact me :)

0
None
DylanT59

Question 5 months ago

Hello,

I would just like to know how will the robot react when approaching a junction.

Thanks

3 more answers
0
None
Isaac Hossam El-DinDylanT59

Answer 5 months ago

Hello,
It depends on the type of the maze .. if the robot is following the right wall it will always turn right as shown in the video ..

I made the robot identifies the type of maze based on the first turn ..

Here 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


And if you have any other queries please contact me :)

0
None
DylanT59Isaac Hossam El-Din

Reply 4 months ago

Hello, thanks for the reply.

Can I also know how did you tune your PID controller? A brief instruction would really help me a lot in my project. I am still new to PID and unsure of the tuning part.

Thanks in advance

0
None
Isaac Hossam El-DinDylanT59

Reply 4 weeks ago

Hello,
I just kept trying different constants, you have to try and find which constant will work as I said earlier it gets effected by fractions and motor power and all that stuff.

Some people will make codes for that and make the controller itself figure it out ..
but that's a little complicated ..

Hope that helped :)

0
None
chester812

Question 5 months ago

Hello Isaac, I saw your striker v1.0 post and I need your help, there are certain pieces of code that I do not understand, could you explain them to me?

are these:

int offset = 5; <- what is this line of code for and why does it have the number 5?

int wall_threshold = 13;

// int left_threshold = 10;

// int right_threshold = 10;

int front_threshold = 7;

What is the wall threshold for and why does it have the number 13 and the front threshold and why does it have the number 7?

Finally, could you explain to me where float errorI has a 2.0 and 3.0?

void pid_start () {

// ReadSensors ()

float errorP = leftSensor - rightSensor;

float errorD = errorP - oldErrorP;

float errorI = (2.0 / 3.0) * errorI + errorP;

Thank you very much, you are a great person and I admire you!

1 more answer
0
None
Isaac Hossam El-Dinchester812

Answer 4 weeks ago

Thank you very much for your kind words ..

<< Offset >>

the offset is used here in calculating errorP .. adding or subtracting the offset helps adjusting the turn speed as it increase the error ..
<< Wall threshold >>
To understand it you need to look at this here ..
it's a condition to define if there is a wall here or not and I made the front threshold lower to avoid early turning ..
it means that the robot will wait tell it gets closer to the front wall to start turning ..

<< errorI >>

to reduce the effect of errorI it's multiplied by 0.6

0.6 = 2/3

in the old versions it was safe to use 2/3 as sometimes 0.6 won't work ..

I hope this helped ..if there is any further quires don't hesitate to contact me :)

unnamed.pngunnamed (1).png
0
None
Abelgetaneh

Question 6 months ago on Step 4

You did a great project, with an amazing tutorial on how to do it. I'm interested in building this project, I was able to find all the parts except the battery. Is there a specific website you recommend or alternate type of battery that can be found easily? Thank you!

3 more answers
0
None
Isaac Hossam El-DinAbelgetaneh

Answer 6 months ago

Thanks a lot, glad that you are interested
for the battery kindly follow this link http://amzn.eu/0cxGV3Q
it will do the trick and if it's not available in your country you can always get the rechargeable packs as a replacement ..
And if you have any other queries please contact me :) ..

0
None
AbelgetanehIsaac Hossam El-Din

Answer 6 months ago

I really appreciate your quick reply. my other question is that when I tried to open the chassis board with adobe illustrator to make the laser cut, I wasn't able to see the right size (dimension), would you be able to provide me the exact size(scale ratio), please? Thank you in advance.

0
None

Hi,
The file was made by CorelDRAW, so it may have some problems with illustrator ..
But the PDF is the exact scale, I used it for printing .. make sure to use it instead of the CorelDRAW File ..