BASIC stamp manual v2.2
POLLIN – BASIC Stamp Command Reference
Page 316 • BASIC Stamp Syntax and Reference Manual 2.2 • www.parallax.com
state). If either I/O pin 0 or 1 goes low, the BASIC Stamp will set I/O pins
2 and 3 high. This works similar to a logical OR operation. The truth table
below shows all the possible states of these two polled-input pins and the
corresponding states the BASIC Stamp will set the polled-output pins to.
Polled-Inputs Polled-Outputs
0 1 2 3
0 0 0 0
0 1 1 1
1 0 1 1
1 1 1 1
Table 5.74: Polled-Inputs /
Polled-Outputs Truth Table.
Normally, any polled-output pins reflect the state changes continuously,
as described above. The POLLMODE command supports another feature,
however, where the polled-output pins will latch the active state; they will
change only once (when the poll state is reached) and stay in the new state
until the PBASIC program tells it to change again. See the POLLMODE
description for more information.
Other possible actions in response to polled-input states are: 1) Running
another program (in a specified program slot), 2) Waiting (pausing
program execution with or without low-power mode) until the poll state is
reached, or 3) Any combination of the above-mentioned actions.
Demo Program (POLL.bsp)
' POLL.bsp
' This program demonstrates POLLIN, POLLOUT, and the use of the POLLMODE
' instruction. Connect active-low inputs to pins 0, 1, 2, and 3. Then
' connect an LED to pin 7. The program will print "." to the Debug
' window until one of the alarm buttons are pressed. This will cause
' the termination of the main loop. At this point the program will
' save the latched bits, clear them (and the polling process), then
' report the input(s) that triggered the alarm.
' {$STAMP BS2p}
' {$PBASIC 2.5}
FDoor PIN 0
BDoor PIN 1
Patio PIN 2
Rst PIN 3
AlarmLed PIN 7
alarms VAR Byte ' alarm bits
P
OLLED-OUTPUTS CAN BE "LATCHED"
ALSO
.
NOTE: This example program can be
used with the BS2p, BS2pe, and BS2px
by changing the $STAMP directive
accordingly.