Introduction: Avoidance Robot Arduino

In the market of robot,there are plenty of smart avoidance robot kit for sale,but I don't like to buy finished kit, to develop old rc car toys in storage box is more challenge.Building an avoidance robot by using its chassis.Installing mini controller and ultrasonic distance sensor module.Driving dual motors by L298N module.

In the beginning, I used L293D dual motor drive IC to drive steering motor and driving motor.It did not success,the robot model need more electrical current than L293D can drive,I have changed to apply L298N drive module which can drive motors up to 2A ,it drive the robot model powerfully.All mechanical problems have been solved.

Next,I founded that ultrasonic sensor has timeout problem ,it send 0 distance signal often.The robot cannot run properly with this noisy signal.Fortunately there are some smart guys can write software to eliminate 0 distance signal.The robot can run smoother without frequently stop and wait the correct distance from ultrasonic sensor.

To build robot on toy chassis is more difficult than using market avoidance robot kit-it has only two driven wheels and a free roller.It can turn to avoid obstruction within narrow space,so the controlling program does not complicate.It has only two rough programming zone-Straight running zone and Avoidance zone.Toy rc car needs more room for turning, it needs more complicate and accurate control.It has four precise programming zones-Long straight running zone,Steering running zone,Avoidance zone and Dead end zone(Obstruction zone).

The ultrasonic distance sensor has a big disadvantage point, it will read correct distance when the reflection angle is within 30 degree.When the robot go to inclined wall more than 30 degree.Sensor will read longer distance value than true distance.It will cause the crash.Some inventor add three sensors to fix this problem.But for this project,the car body is small,one sensor is enough.

Finally,after working a couple of month to develop toy rc car to be robotic vehicle is possible.

You can purchase electronic parts from Aliexpress, Banggod,Ebay,etc.

Project more : http://hobbywitch666.blogspot.com

Step 1: Materials and Tools

Materials

1. Arduino controller - Pro Mini 3.3V/5V

2. 2-LEDs (Different color)

3.2-Resistor 1 kOhm. 1/4 watt.

4. Ultrasonic Distance Sensor Module (HC-SR04)

5. L298N dual motor drive module

6. Dupont wires.

7.PCB - DIY circuit board or prototype bread board.

8.Motor size 120

9.Motor size 180

10.Battery 5-9 V.

Tools

1. Soldering gun.

2. Soldering wire.

3. Soldering paste.

4. Screw driver.

5. Plier.

6.Hot glue gun.

7.Screw , Bolt & Nut.

Step 2: Electronic Parts Installation & Wiring

Arduino Pro Mini pins No.

2 - Green LED

3 - Trigger pin

4 - Echo pin

5 - ENA

6 - IN1

7 - IN2

8 - ENB

9 - IN3

10 - IN4

L298N motor drive module

OutputA - Steering motor

OutputB - Driving motor

+12V - Battery positive pole

GND - Connect Battery negative pole and Mini controller GND pin together.

+5V - Mini controller Vcc pin

* Don't use too small wire gauge,nevertheless controller pin will always HIGH status.

* Soldering need skill and extra cleanliness to prevent small electrical touching points.

* Checking short circuit before connect power supply battery is necessary.

Step 3: Software Download & Upload to Controller

Arduino sketch and Library :

1.Down load attached sketch file .ino and library zip file S05RF (This library file use with new ultrasonic sensor module HY-SRF05 but it can be applied to old model HC-SR04,they said it shall eliminate 0 noisy signal and better than older libraryNewPing_v1.7).Add the library to your Arduino saftware.

2.Comply and upload .ino sketch to Arduino mini controller.(This sketch valid for Arduino UNO/Nano/Pro Mini 5V / 3.3V)

3.Open Arduino serial monitor to see the output.

Observe ultrasonic sensor read distance value by varying different distance to detect.(This attached sketch read in centimeter unit.) If there are some 0 distance,it's normal.But If there are many continuous 0 distance,perhaps the ultrasonic sensor is defective.

4.Let's the robot test run on floor by laying obstructive object around.Collect every problems for editing the sketch.

5.The speed of two motor can be adjusted to match the robot size,weight and battery power that you assembled by changing PWM value in command analogWrite(enableA, PWM) and analogWrite(enableB, PWM );from 0 to 255.(in attached sketch is 150 for steering motor and 100 for driving motor)

To calibrate the robot speed,timing,appropriate distance zone and driving power is very difficult step.It needs2 time and experience to run the robot properly.

Thank to the people in Arduino play ground who share experiences to solve many problems till the project achieved.