loading
PINGBot is the Explorer Robot that uses an ultrasonic sensor to be able to dodge objects present in its path.

The ultrasonic sensor emits pulses at a frequency of 40KHz (imperceptible to the human ear and animals), these pulses when hitting an object, they are reflected and return to the sensor after a certain time; knowing the total time round the wrists and the speed of sound in the medium (the air), it is easy to calculate the distance traveled by the wrists and thus determine the distance of the object relative to the sensor.
See the post about PING sensor for details in https://www.instructables.com/id/Basic-Principles/ 

We will use the same chassis of the BUGBot https://www.instructables.com/id/Basic-Principles/ ... but currently with a dual H-BRIDGE / L298H to control two DC motors (control direction and speed), which will give greater flexibility to our prototype.

The basic operation is as follows:

When booting the robot will remain stopped and the sensor calculates the distance FRONT, RIGHT and LEFT, he will compare these distance with a threshold distance (i.e.20 cm) so it can decide which is the best way to forward (the longest path will always be the best option! ).
After that the Robot will begin to running forward until the moment they will find an object interfering with your progress (it should approach the maximum limit up to a distance, in inches, of the object), when it happens: it will stop and analise again distances: FRONT, RIGHT and LEFT, so he could again decide which is the best way to forward - returning again to the operating cycle.

Step 1: Programming Logic

Speaking in terms of logic of programming, we have:

- including libraries;
- initialize variables and constants;
- define and initialize the pins;
- initialize serial communication;
- "BEGIN"
- call routine to stop motors;
- positioning servo to 90 degrees;
- read FRONT distance and store;
- servo position at 0 degrees;
- read LEFT distance and to store;
- positioning servo to 180 degrees;
- read RIGHT distance and to store;
- comparison (1): FRONT is greater than LEFT?;
- yes: - comparison (2): FRONT is greater than RIGHT?;
- yes: - call routine to move forward;
- no: - call routinel to turn right;
- no: - (comparison (1) is less than: - call routine to turn left;
- If any condition is possible (all distances are exactly equals: - move forward and stop for a while, and so begin the cycle again.
- walking distance to detect less than 20 cm;
- loop to the "BEGIN";

Note - 1:
The motors must be connected in order to have the same rotation speed and  direction, so that to take the robot forward - high value on pin 2 of each motor and pin 1 maintained at a low level.

The flowchart show us, how to perform these programming functions (only as example):

Note - 2:
Using the same hardware, a second version with a simpler code was created. Where the operation is as below:

Initially the robot walks forward until he encounter an obstacle at a distance less than the distance limit;
Then he analyzes the "Right" distance - If the "Right" distance is greater than the limit distance - he chooses to turn "Right" and move forward;
If the "Right" distance is smaller than the limit distance - he analyses the "Left"  distance - if the "Left" distance is greater than the limit distance - he chooses to turn "Left" and move forward;
If none of the distances, both "Right" and "Left" is not satisfactory - he turn 180 degrees and move forward.
Starting a new cycle.

In the Software and Programming section, you will find both versions for download.

Step 2: Hardware and Materials

In this section we will examine the needs in terms of materials and hardware used.

We will use the chassis built for BUGBot - Light Follower Robot.
See the post for more construction details...  https://www.instructables.com/id/Basic-Principles/


Material List:
1 x Arduino UNO, Mega, Duemilanove, Duecemila or Teensy + + 2.0
1 x Ultrasonic Sensor HC-SR04
1 x Dual H-BRIDGE
1 x Servo Motor HXT900 9g / 1.8 Kg
1 x Kit Tamiya Gear Box with two 3-6V DC motors
Battery pack to power the Arduino and motors (9V)
Chassis for mounting
Wires and cables for connections.

Step 3: Layout and Schematics

The Arduino power feed, can be used from the H-Bridge.
I advise to use an independent power feed but with GNDs in common
between Arduino and H-Bridge. (due to high current drawn by the motor)

Take care to not reverse the connections of power feed ... the damage may be irreversible.

Pins Correspondence:
Arduino pins -X- External devices' pins:


0 -> N / A
1 -> N / A
2 -> N / A
3 -> PING Sensor echo pin
4 -> PING Sensor Trigger pin
5 -> H-BRIDGE port-A enable pin
6 -> H-BRIDGE in1 pin
7 -> H-BRIDGE in2 pin
8 -> H-BRIDGE in3 pin
9 -> H-BRIDGE in4 pin
10 -> to attach the servo motor
11 -> H-BRIDGE port-B enable pin
12 -> buzzer
13 -> N / A

"I had many problems with noise in the distance sensor system, which was solved by
adding 100nF capacitor between pins of the DC motors and their
carcasses (besides the capacitor which is usually added among its pins).

Step 4: Software and Programming

Many versions were created in the construction initial phase of the PINGBot.
It were created a version to manage the DC motors (direction, speed, to turn left, to turn right and for to turn 180 degrees).

And also were created the continous rotation servo motor's version. If you need this version, contact me please and I am willing to help you.

I had a lot of work to do the final adjustments in the Robot (and I think that is not too good so far). First, because the DC motors noise as I already commented, and then for the movements adjust and batery consuption.

About 30 hours were spent in this project. I believe that for any kind of chassis, we will need spent time for the adjustments and debug.

You can download the arduino sketches and libraries directly from the GitHub below:

https://github.com/Arduinobymyself/PINGBot.git

Step 5: Videos

Watch directly on YouTube, or on screencast (for better quality and download).
I am so sorry, but the videos are in Portuguese yet.


PINGBot version 4 (video 1):
screencast: http://www.screencast.com/t/C6KN0SNhO69p
youtube: http://youtu.be/h5sZfQm27yI

 

PINGBOT version 4 (video 2):
screencast: http://http://www.screencast.com/t/lMa4ZLQIAJj
youtube: http://youtube.com/watch?v=T-sAsfuGtDs

 

PINGBot version 5:
screencast: http://www.screencast.com/t/7pmwaWJhu4dy
youtube: http://youtu.be/b4cjVJgoDPc

 

PINGBot - General operation of the Robot, in action - leaving a deadlock.
screencast: http://www.screencast.com/t/9Uow4fyDy
youtube: http://www.youtube.com/watch?v=KMZmRc_-FhQ

 










Others Projects:

https://www.instructables.com/id/LINUSBot-Line-Follower-Robot/
https://www.instructables.com/id/Basic-Principles/
https://www.instructables.com/id/Dual-H-Bridge-L298-Breakout-Board-Homemade/
https://www.instructables.com/id/3x3x3-LED-Cube-1/
https://www.instructables.com/id/LINUSBot-Line-Follower-Robot-with-PID-control/

Step 6: Pictures and Photos

The problem of battery compartment, was solved using two plastic parts (used in carpentry and furniture making).
The parts were placed on top of the 360 degrees wheel, using the same fixing screws (or ball caster if you are using).
In this way the problem was solved and gave more stability to the chassis.

Note that the DC motor battery is rechargeable type ... it helps us to save money and give more energy to the car.
Use a 9V/900mAh Nickel Metal Hydride (NiMH) batery.
<p>Hi Sir!</p><p>My name is Himu,from Bangladesh.</p><p>Can you sent me the code and libraries please.</p><p>My email:asmhemu@gmail.com</p><p>Thank you!</p>
<p>Humm.. According Arduino specs, you should provide at least 7V to arduino.</p><p>So, the connection from the +5V on the bridge to the arduino Vin PIN will provide less input that required for stable operation. Certainly better to use external power source for arduino!</p>
<p>I have build the bot based on the chineese knockoff, I have tested all subsystems to veryfi they run, but when i load the sw it misses the ping and wprogram. i just have updated to ide 1,60</p><p>du you have an updated version ?</p><p>cheers</p><p>larsboi@hotmail.com</p>
<p>Hi Sir!<br>My name is Duy&ecirc;n, i come from Viet Nam.<br>Can you sent me the code, My email:tranduyenit@gmail.com<br>Thank you! </p>
<p>hello ... I want the code if u can </p><p>ramboo_77@yahoo.com</p>
<p>Hello my friend could you send the code to me also? fotiou5@yahoo.gr</p>
can i get the program ...................
Hi Preddy<br><br>Sure I can share the code with you.<br><br>Send me an email and I will be glad to send you the code and libraries.<br><br><br>Cheers<br><br>Marcelo Moraes<br>arduinobymyself@gmail.com
Hi<br><br>Send me an email and I can share the code with you.<br>arduinobymyself@gmail.com<br><br>
<p>hello alos can you send me codes please. ı want make that for my project of lesson. my e-mail is :</p><p>satogluibrahim@gmail.com</p><p>ı sent you an e-mail if you received to it .</p>
<p>preddy126@gmail.com</p><p>pls send me code to above email id....</p>
Hi Preddy126<br><br>For sure. I am sending the code to your email.<br><br>Regards<br><br>Marcelo Moraes<br>arduinobymyself.blogspot.com.br<br>arduinobymyself@gmail.com

About This Instructable

14,706views

71favorites

License:

Bio: I am 43 years old and I live in Brazil. I am a Telecommunication / Electronics Engineer. Sixteen years acting in the industry of "Telecommunication and ... More »
More by BIGDOG1971:Arduino Propeller Message Display (POV) ARDUINO By Myself Mini-CNC (Plotter) ROVER Bot - The Arduino Bluetooth Controlled Tank 
Add instructable to: