5: BASIC Stamp Command Reference – POT
BASIC Stamp Programming Manual 2.0c
•
www.parallaxinc.com
•
Page 239
POT
BS1
BS2 BS2e BS2sx BS2p
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.25.
POT works by first setting the specified I/O pin to an output and setting
its state high. This step 5 volts on one side of the capacitor (see
Figure 5.25) 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
1
2
e
2
sx
2
p
2
P0
5 k
Ω
to 50
k
Ω
variable resistance
Vss
0.1 uF
Figure 5.25: Example Variable
Resistance Circuit.
H
OW
POT
REALLY WORKS
.
Summary of Contents for BASIC Stamp 2e
Page 1: ...BASIC Stamp Programming Manual Version 2 0c...
Page 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...