POLLWAIT - BASIC Stamp Command Reference
Page 236 • BASIC Stamp Programming Manual 2.0b • www.parallaxinc.com
The POLLWAIT command is unique among the polling commands in that
it actually causes execution to halt, until a polled-input pin event occurs.
The Period argument is similar to that of the NAP command; using the
values 0 to 7 specifies the duration of the low-power period. After the
low-power period is over, the BASIC Stamp polls the polled-input pins
and determines if any meet the desired poll state. If no polled-input is in
the desired state (as set by POLLIN command) the BASIC Stamp goes
back into low-power mode, again, for the same duration as before. If any
polled-input is in the desired state, however, the BASIC Stamp will
continue execution with the next line of code.
A Period of 8, makes the BASIC Stamp pause execution in normal running
mode (not low-power mode) until a polled-input event occurs. The
response time is indicated in Table 5.60. Since the response time is so fast,
this feature can be used to synchronize a portion of PBASIC code to an
incoming pulse.
Period Length of Low-Power Mode
0 18 ms
1 36 ms
2 72 ms
3 144 ms
4 288 ms
5 576 ms
6 1152 ms (1.152 seconds)
7 2304 ms (2.304 seconds)
8 No power-down
The following is a simple example of the POLLWAIT command.
POLLIN 0, 1
Loop:
POLLWAIT 0
TOGGLE 1
GOTO Loop
In this example, the POLLIN command sets I/O pin 0 to be a polled-input
pin looking for a high (1) state. The Loop routine immediately runs a
POLLWAIT command and specifies a Period of 0 (with results in a low-
power state of 18 ms). This means that every 18 ms, the BASIC Stamp
wakes-up and checks I/O pin 0 for a high. If I/O pin 0 is low, it goes back
A SIMPLE POLLWAIT EXAMPLE.
Table 5.61: Period values and
associated low-power modes.