POLLRUN - BASIC Stamp Command Reference
Page 232
•
BASIC Stamp Programming Manual 2.0b
•
www.parallaxinc.com
POLLIN 0, 1
POLLRUN 1
POLLMODE 3
Loop:
DEBUG "Waiting in Program Slot 0…", CR
GOTO Loop
The first line of the above code will set up I/O pin 0 as a polled-input pin
looking for a high (1) state. The second line, POLLRUN, tells the BASIC
Stamp that when I/O pin 0 goes high, it should switch execution over to
the program residing in program slot 1. The third line, POLLMODE,
activates the polled-run configuration.
Once the BASIC Stamp reaches the Loop routine, it will continuously print
"Waiting in Program Slot 0…" on the PC screen. In between reading the
DEBUG and GOTO commands, however, the BASIC Stamp will poll I/O
pin 0 and check for a high or low state. If the state of pin 0 is low, it will
do nothing and continue as normal. If the state of pin 1 is high, it will
switch execution over to the program in slot 1 (the second program is not
shown in this example). The switch to another program slot works exactly
like with the RUN command; the designated program is run and the
BASIC Stamp does not "return" to the previous program (similar to a
GOTO command).
Note that in order for the polled-run activity to occur, the poll mode must
be set to either 3 or 4 (the two modes that activate polled-run). Also note,
that the polled-run modes, 3 and 4, are unique. As soon as the polled-run
action occurs, the mode switches to 1 (deactivated, saved) or 2 (activated,
outputs), respectively. This is so that the BASIC Stamp doesn't
continuously go to the start of the designated program slot while the
polled-inputs are in the desired poll state. Without this "one shot" feature,
your program would appear to lock-up as long as the polled-inputs are in
the designated state.
After the program switch takes place, the Slot value is maintained. Any
future change to poll mode 3 or 4, without another POLLRUN command,
will result in the previously defined program slot being used.
Summary of Contents for BASIC Stamp 1
Page 1: ...BASIC Stamp Programming Manual Version 2 0c...
Page 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...