
Figure 2.17B shows how a single analog input can be used to read two switches.
When both switches are open, the analog input will read 5 V. When switch S1 is
closed, the analog input will read 3.9 V. When switch S2 is closed, the input will
read 3.4 V, and when both switches are closed, the input will read 2.9 V. Instead
of switches, you could also use this technique to read the state of open-collector or
open-drain digital signals.
Figure 2.17C shows how a thermistor or other variable-resistance sensor can
be combined with an output. The microcontroller pin is programmed as an
analog input to read the temperature. When the pin is programmed as an output ...