BASIC stamp manual v2.2
4: BASIC Stamp Architecture – PIN Symbols
BASIC Stamp Syntax and Reference Manual 2.2 • www.parallax.com • Page 101
' {$PBASIC 2.5}
signal PIN 2 ' pin-type symbol representing I/O 2
OUTPUT signal ' set signal pin to output
signal = 1 ' set signal high
The OUTPUT command treats signal as a constant equal to 2 and the
signal = 1 statement treats signal as a variable equal to the output variable
for the defined pin (OUT2 in this case).
You might be wondering why “signal = 0” in the IF…THEN statement of
our first example treats signal as the input variable IN1 and yet “signal =
1” in our last example treats signal as the output variable OUT2. The
distinction is that the first example is a comparison and the second
example is an assignment. Comparisons need to “read” expressions and
then evaluate the comparison while assignments need to read expressions
and then “write” the results. Since signal is to the left of the equal sign (=)
in our assignment statement, it must be a variable we can write to, thus it
must be treated as OUT2, in this case.
What happens if our pin-type symbol is to the right of the equal sign in an
assignment statement? Example:
' {$PBASIC 2.5}
signal1 PIN 1 ' pin-type symbol representing I/O 1
signal2 PIN 2 ' pin-type symbol representing I/O 2
INPUT signal1 ' set signal1 pin to input
OUTPUT signal2 ' set signal2 pin to output
signal2 = signal1 ' set signal2 pin to signal1 pin’s state
In this case signal2 is treated as OUT2 and signal1 is treated as IN1; left side
must be written to and right side must be read from.
If a pin-type symbol is used in a command, but not in the Pin argument of
that command, it will be treated as an input variable (i.e.: INx). NOTE: It
is very rare that you’ll need to use a pin-type symbol in this way.
The following is a summary of behaviors and uses of pin-type symbols.
All
2
All
2