What You Need
1. A Parallax PING))) sensor
2. A TMP36 temperature sensor from Analog Devices
3. A breadboard
4. Some wires
5. An Arduino board, such as the Uno, Duemilanove, or Diecimila
6. A USB cable to connect the Arduino to your computer
Measuring Distances with an Ultrasonic Sensor
Measuring distances automatically and continuously comes in handy in many
situations. Think of a robot that autonomously tries to find its way or of an
automatic burglar alarm that rings a bell or calls the police whenever someone
is too near your house or the Mona Lisa. All this is possible with Arduino.
But before you can create that burglar alarm or robot, you need to understand
some key concepts.
Many different types of sensors for measuring distances are available, and
the Arduino plays well with most of them. Some sensors use ultrasound,
while others use infrared light or even laser. But in principle all sensors work
the same way: they emit a signal, wait for the echo to return, and measure
the time the whole process took. Because we know how fast sound and light
travel through the air, we can then convert the measured time into a distance.
In our first project, we’ll build a device that measures the distance to the
nearest object and outputs it on the serial port. For this project, we use the
Chapter 5. Sensing the World Around Us • 78
report erratum • discuss
www.it-ebooks.info