Hardware Reference
In-Depth Information
NOTE
This code in Example 2-5 uses .toFixed(3) to print only three digits past the decimal.
Otherwise, the output could have many extra digits. Try removing .toFixed(3) and see
what happens.
A variable resistor with two terminals
Some resistive sensors have only two terminals, such as the flex sensor in Figure 2-9 . The
resistance between its two terminals changes when it is flexed. In this case, we need to
add a fixed resistor in series with the flex sensor. Figure 2-9 shows how to wire in a 22 kΩ
resistor to give a voltage to measure across the flex sensor.
Figure 2-9. Reading a two-terminal flex resistor
The code in Example 2-5 also works for this setup.
Search WWH ::




Custom Search