BASIC stamp manual v2.2
POLLOUT – BASIC Stamp Command Reference
Page 326 • BASIC Stamp Syntax and Reference Manual 2.2 • www.parallax.com
This feature should not be confused with the concept of interrupts, as the
BASIC Stamp does not support true interrupts.
The POLLOUT command achieves one of three possible actions in
response to a polled-input event. This command works in conjunction
with the POLLIN and POLLMODE commands. The following is an
example of the POLLOUT command:
POLLIN 0, 0
POLLOUT 1, 1
POLLMODE 2
Main:
DEBUG "Looping...", CR
GOTO Main
In this example, the POLLOUT command tells the BASIC Stamp to set I/O
pin 1 to an output mode and set it high (1) when it detects the desired poll
state. The poll state is the low (0) level on I/O pin 0 that POLLIN told it to
look for. If the polled-input pin is high, the BASIC Stamp will set
polled-output pin 1 to low (0), instead. The BASIC Stamp will not actually
start polling until it is set to the appropriate mode, however. The third
line, POLLMODE, initiates the polling process (see the POLLMODE
description for more information). From then on, as the BASIC Stamp
executes the rest of the program, it will check for a low level (logic 0) on
I/O pin 0, in-between instructions.
Once the program reaches the endless loop, it will continuously print
"Looping…" on the PC screen. In between reading the DEBUG command
and the GOTO command (and vice versa) it will check polled-input pin 0
and set polled-output pin 1 accordingly. In this case, when I/O pin 0 is set
high, the BASIC Stamp will set I/O pin 1 low. When I/O pin 0 is set low,
the BASIC Stamp will set I/O pin 1 high. It will continue to perform this
operation, in-between each command in the loop, endlessly.
It's important to note that in this example only the DEBUG and GOTO
commands are being executed over and over again. The first three lines of
code are only run once, yet their effects are "remembered" by the BASIC
Stamp throughout the rest of the program.
If the polling commands were not used, the program would have to look
like the one below in order to achieve the same effect.
A SIMPLE POLLOUT EXAMPLE.
F
OR COMPARISON: ACHIEVING THE SAME
EFFECTS WITHOUT THE POLLING
COMMANDS
.
T
HE BASIC STAMP "REMEMBERS" THE
POLLING CONFIGURATION FOR THE
DURATION OF THE
PBASIC PROGRAM.