BASIC stamp manual v2.2

INPUT – BASIC Stamp Command Reference
Page 244 BASIC Stamp Syntax and Reference Manual 2.2 www.parallax.com
on the BS1) will appear on the pin. The demo program shows how this
works.
Demo Program (INPUT.bs1)
' INPUT.bs1
' This program demonstrates how the input/output direction of a pin is
' determined by the corresponding bit of DIRS. It also shows that the
' state of the pin itself (as reflected by the corresponding bit of PINS)
' is determined by the outside world when the pin is an input, and by the
' corresponding bit of OUTS when it's an output. To set up the demo,
' connect a 10k resistor from +5V to P7 on the BASIC Stamp. The resistor
' to +5V puts a high (1) on the pin when it's an input. The BASIC Stamp
' can override this state by writing a low (0) to bit 7 of OUTS and
' changing the pin to output.
' {$STAMP BS1}
' {$PBASIC 1.0}
Main:
INPUT 7 ' Make P7 an input
DEBUG "State of P7: ", #PIN7, CR
PIN7 = 0 ' Write 0 to output latch
DEBUG "After 0 written to OUT7: "
DEBUG #PIN7, CR
OUTPUT 7 ' Make P7 an output
DEBUG "After P7 changed to output: "
DEBUG #PIN7
Demo Program (INPUT.bs2)
' INPUT.bs2
' This program demonstrates how the input/output direction of a pin is
' determined by the corresponding bit of DIRS. It also shows that the
' state of the pin itself (as reflected by the corresponding bit of INS)
' is determined by the outside world when the pin is an input, and by the
' corresponding bit of OUTS when it's an output. To set up the demo,
' connect a 10k resistor from +5V to P7 on the BASIC Stamp. The resistor
' to +5V puts a high (1) on the pin when it's an input. The BASIC Stamp
' can override this state by writing a low (0) to bit 7 of OUTS and
' changing the pin to output.
' {$STAMP BS2}
' {$PBASIC 2.5}
Main:
INPUT 7 ' Make P7 an input
DEBUG "State of P7: ",
1
All
2
NOTE: This example program can be
used with all BS2 models by changing
the $STAMP directive accordingly.