Hardware Reference
In-Depth Information
UsingAnalogSensors
Although potentiometers generate an analog voltage value on a pin, they aren't
really sensors in the traditional sense. They “sense” your turning of the dial,
but that gets boring pretty quickly. The good news is that all kinds of sensors
generate analog output values corresponding to “real-world” action. Examples
of such include the following:
Accelerometers that detect tilting (many smartphones and tablets now
have these)
Magnetometers that detect magnetic fields (for making digital compasses)
Infrared sensors that detect distance to an object
Temperature sensors that can tell you about the operating environment
of your project
Many of these sensors are designed to operate in a manner similar to the
potentiometer you just experimented with: You provide them with a power (VCC)
and ground (GND) connection, and they output an analog voltage between VCC
and GND on the third pin that you hook up to your Arduino's ADC.
For this next experiment, you get to choose what kind of analog sensor you
want to use. They all output a value between 0V and 5V when connected to
an Arduino, so they will all work the same for your purposes. Here are some
examples of sensors that you can use:
Sharp Infrared Proximity Sensor
www.exploringarduino.com/parts/IR-Distance-Sensor
Connector: www.exploringarduino.com/parts/JST-Wire
The Sharp infrared distance sensors are popular for measuring the dis-
tance between your project and other objects. As you move farther from
the object you are aiming at, the voltage output decreases. Figure 5 in the
datasheet from the part webpage linked above shows the relationship
between voltage and measured distance.
TMP36 Temperature Sensor
www.exploringarduino.com/parts/TMP36
The TMP36 temperature sensor easily correlates temperature readings
in Celsius with voltage output levels. Since every 10mV corresponds to
1$C, you can easily create a linear correlation to convert from the voltage
you measure back to the absolute temperature of the ambient environ-
ment: $C = [(Vout in mV) - 500]/10. The offset of -500 is for dealing with
temperatures below 0$C. The graph in Figure 3-7 (extracted from the
datasheet) shows this conversion.
Search WWH ::




Custom Search