POLLIN - BASIC Stamp Command Reference
Page 216
•
BASIC Stamp Programming Manual 2.0b
•
www.parallaxinc.com
This feature should not be confused with the concept of interrupts, as the
BASIC Stamp does not support true interrupts.
The following is an example of the POLLIN command:
POLLIN 0, 1
POLLMODE 2
The POLLIN command in the above code will cause the BASIC Stamp to
set I/O pin 0 to an input mode and get ready to poll it for a high (1) state.
The BASIC Stamp will not actually start polling until it is set to the
appropriate mode, however. The second 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 high level (logic 1) on I/O pin 0, in-between instructions.
In the code above, no obvious action will be noticed since we didn't tell the
BASIC Stamp what to do when it detects a change on the I/O pin. One
possible action the BASIC Stamp can be instructed to take is to change the
state of an output, called a polled-output. Take a look at the next example:
POLLIN 0, 1
POLLOUT 1, 0
POLLMODE 2
Loop:
DEBUG "Looping…", CR
GOTO Loop
In this example, in addition to an endless loop, we've added another
polling command called POLLOUT (see the POLLOUT description for
more information). Our POLLOUT command tells the BASIC Stamp to set
I/O pin 1 to an output mode and set it low (0) when it detects the desired
poll state. The poll state is the high (1) level on I/O pin 0 that POLLIN
told it to look for. If the polled-input pin is not high, it will set
polled-output pin 1 to high (1), instead.
Once the program reaches the endless loop, called 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
A
SIMPLE
POLLIN
EXAMPLE
.
S
ETTING ONE OF THE POSSIBLE
ACTIONS
:
POLLED
-
OUTPUTS
Содержание BASIC Stamp 2e
Страница 1: ...BASIC Stamp Programming Manual Version 2 0c...
Страница 30: ...Introduction to the BASIC Stamps Page 28 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 90: ...BUTTON BASIC Stamp Command Reference Page 88 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 118: ...END BASIC Stamp Command Reference Page 116 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 128: ...FREQOUT BASIC Stamp Command Reference Page 126 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 196: ...NAP BASIC Stamp Command Reference Page 194 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 206: ...OWIN BASIC Stamp Command Reference Page 204 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 214: ...OWOUT BASIC Stamp Command Reference Page 212 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 216: ...PAUSE BASIC Stamp Command Reference Page 214 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 226: ...POLLMODE BASIC Stamp Command Reference Page 224 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 232: ...POLLOUT BASIC Stamp Command Reference Page 230 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 236: ...POLLRUN BASIC Stamp Command Reference Page 234 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 240: ...POLLWAIT BASIC Stamp Command Reference Page 238 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 262: ...RCTIME BASIC Stamp Command Reference Page 260 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 274: ...RUN BASIC Stamp Command Reference Page 272 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 310: ...SEROUT BASIC Stamp Command Reference Page 308 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 324: ...STOP BASIC Stamp Command Reference Page 322 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...