CHAPTER 5
Sensing the World Around Us
Instead of communicating via mouse or keyboard as with regular computers,
you need to connect special sensors to the Arduino so that it can sense
changes around it. You can attach sensors that measure the current temper-
ature, the acceleration, or the distance to the nearest object.
Sensors make up an important part of physical computing, and the Arduino
makes using various sensor types a breeze. In this chapter, we will use both
digital and analog sensors to capture some real-world state, and all we need
is a couple of wires and some small programs.
We’ll take a close look at two sensor types: an ultrasonic sensor that measures
distances and a temperature sensor that measures, well, temperatures. With
the ultrasonic sensor, we’ll build a digital metering rule to help us measure
distances remotely.
Although ultrasonic sensors deliver quite accurate results, we can still improve
their precision with some easy tricks. Interestingly, the temperature sensor
will help us with this, and at the end of the chapter, we will have created a
fairly accurate digital distance meter. We’ll also build a nice graphical appli-
cation that visualizes the data we get from the sensors.
But the Arduino doesn’t only make using sensors easy. It also encourages
good design for both your circuits and your software. For example, although
we end up using two sensors, they are completely independent. All the pro-
grams we develop in this chapter will run without changes on the final circuit.
report erratum • discuss
www.it-ebooks.info