EasyManuals Logo

Arduino Pro Mini User Manual

Arduino Pro Mini
311 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #97 background imageLoading...
Page #97 background image
Parallax PING))) ultrasonic sensor
1
because its easy to use, comes with
excellent documentation, and has a nice feature set. It can detect objects in
a range between 2 centimeters and 3 meters, and we use it directly with a
breadboard, so we dont have to solder. Its also a perfect example of a sensor
that provides information via variable-width pulses. (More on that in a few
paragraphs.) With the PING))) sensor, we can easily build a sonar or a robot
that automatically finds its way through a maze without touching a wall.
As mentioned earlier, ultrasonic sensors usually
dont return the distance to the nearest object.
Instead, they return the time the sound needed
to travel to the object and back to the sensor.
The PING))) is no exception, and its innards are
fairly complex. Fortunately, they are hidden
behind three simple pins: power, ground, and
signal.
This makes it easy to connect the sensor to the
Arduino. First, connect Arduinos ground and
5V power supply to the corresponding PING)))
pins. Then connect the PING)))s sensor pin to
one of the Arduinos digital IO pins. (Were using
pin 7 for no particular reason.) For a diagram and for a photo of our circuit,
see Figure 15, PING))) basic circuit, on page 80 and Figure 16, Photo of PING)))
basic circuit, on page 81.
To bring the circuit to life, we need some code that communicates with the
PING))) sensor:
InputDevices/Ultrasonic/Simple/Simple.ino
const unsigned int PING_SENSOR_IO_PIN = 7;
Line 1
const unsigned int BAUD_RATE = 9600;
-
-
void setup() {
-
Serial.begin(BAUD_RATE);
5
}
-
-
void loop() {
-
pinMode(PING_SENSOR_IO_PIN, OUTPUT);
-
digitalWrite(PING_SENSOR_IO_PIN, LOW);
10
delayMicroseconds(2);
-
-
digitalWrite(PING_SENSOR_IO_PIN, HIGH);
-
delayMicroseconds(5);
-
1.
http://www.parallax.com/product/28015
report erratum discuss
Measuring Distances with an Ultrasonic Sensor 79
www.it-ebooks.info

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Arduino Pro Mini and is the answer not in the manual?

Arduino Pro Mini Specifications

General IconGeneral
BrandArduino
ModelPro Mini
CategoryMotherboard
LanguageEnglish

Related product manuals