5: BASIC Stamp Command Reference – POLLWAIT
BASIC Stamp Programming Manual 2.0c
•
www.parallaxinc.com
•
Page 237
to sleep for another 18 ms. If I/O pin 0 is high, it runs the next line of
code, which toggles the state of I/O pin 1. Then the loop starts all over
again. Note: Due to the nature of low-power mode, I/O pin 1 may toggle
between high and low (at 18 ms intervals in this case) even if I/O pin 0
stays low. This is an artifact of the "reset" condition in the interpreter chip
that occurs when the chip wakes up from a low-power state. Upon this
"reset" condition, all the I/O pins are switched to inputs for apx. 18 ms. It
is the switching to inputs that will cause I/O pin 1 to appear to toggle. See
the NAP or SLEEP commands for more information.
If low-power mode is not required, change the POLLWAIT command in
the example above to "POLLWAIT 8" instead. This will have the effect of
keeping the BASIC Stamp in normal running mode (ie: no low-power
glitches) and will also cause the TOGGLE command to execute in a much
shorter amount of time after a polled-input event occurs.
Demo Program (POLLWAIT.bsp)
' This program demonstrates the POLLWAIT command. I/O pin 0 is set to watch for a
' high signal. Once the Loop routine starts running, the POLLWAIT command causes the
' program to halt until the polled event happens (I/O pin is high) then it prints
' a message on the PC screen. It will do nothing until I/O pin is high.
'{$STAMP BS2p} 'STAMP directive (specifies a BS2p)
POLLIN 0, 1 'Set I/O 0 to polled-input looking for a high
POLLMODE 2 'Set mode to enable polled-outputs and polled wait
Loop:
POLLWAIT 8 'Wait for polled event (in normal power mode)
DEBUG "I/O 0 is HIGH!", CR 'Print to the screen when polled event occurs
GOTO Loop
p
2
Summary of Contents for BASIC Stamp 2e
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...