BASIC stamp manual v2.2
5: BASIC Stamp Command Reference – POT
BASIC Stamp Syntax and Reference Manual 2.2 • www.parallax.com • Page 339
POT
BS1 BS2 BS2e BS2sx BS2p BS2pe BS2px
POT Pin, Scale, Variable
(See RCTIME)
Function
Read a 5 kΩ to 50 kΩ potentiometer, thermistor, photocell, or other
variable resistance.
• Pin is a variable/constant (0 – 7) that specifies the I/O pin to use.
This pin will be set to output mode initially, then to input mode.
• Scale is a variable/constant (0 – 255) used to scale the command's
internal 16-bit result. See explanation below for steps to finding the
scale value to use for your circuit.
• Variable is a variable (usually a byte) where the final result of the
reading will be stored. Internally, the POT command calculates a
16-bit value, which is scaled down to an 8-bit value.
Explanation
POT reads a variable resistance and returns a value (0 – 255) representing
the amount of time it took to discharge the capacitor through the
resistance. Pin must be connected to one side of the variable resistance,
whose other side is connected through a capacitor to ground, as shown in
Figure 5.27.
Figure 5.27: Example Variable
Resistance Circuit.
P0
5 k
Ω
to 50
k
Ω
variable resistance
Vss
0.1 uF
POT works by first setting the specified I/O pin to an output and setting
its state high. This step places +5 volts on one side of the capacitor (see
Figure 5.27) and ground (0 volts) on the other side, which charges the
capacitor. POT waits for 10 ms and then sets the I/O pin to an input mode
and starts its timer. Initially the I/O pin will see a high (1) that will
eventually drop to a low (0) when the capacitor discharges past the 1.4-
volt threshold. The timer stops once the low is seen. The value of the
HOW POT REALLY WORKS.
1
All
2