Page 105 - Programming the Photon Getting Started With the Internet of Things
P. 105
Reading a Potentiometer
The easiest analog sensor that we can read is a simple potentiometer (POT). You can find
these in most electronic kits, and they are fairly common and inexpensive; you can even
salvage these from old consumer electronics such as stereos, speakers, thermostats, and
more. A potentiometer is a variable-voltage divider that looks like a dial knob, as shown in
Figure 5.5. They can vary in size and shape, but they all have one thing in common, which
is that they all use three pins. In our case, you connect one of the outer pins to ground and
the other outer pin to 3V3. Potentiometers are also symmetrical, which means it does not
matter how you connect the ground and 3V3, as long as it is not the middle pin. The
middle pin connects to the analog pin on the Photon, as shown in Figures 5.5 and 5.6.
Figure 5.5 Potentiometer connected to the Photon.