Specifications
BASIC Stamp II
Parallax, Inc. • BASIC Stamp Programming Manual 1.8 • Page 249
2
Button
BUTTON
pin, downstate, delay, rate, bytevariable, targetstate, address
Debounce button input, perform auto-repeat, and branch to address if
button is in target state. Button circuits may be active-low or active-
high.
•
Pin
is a variable/constant (0–15) that specifies the I/O pin to use.
This pin will be made an input.
•
Downstate
is a variable/constant (0 or 1) that specifies which
logical state occurs when the button is pressed.
•
Delay
is a variable/constant (0–255) that specifies how long the
button must be pressed before auto-repeat starts. The delay is
measured in cycles of the Button routine. Delay has two special
settings: 0 and 255. If Delay is 0, Button performs no debounce or
auto-repeat. If Delay is 255, Button performs debounce, but no
auto-repeat.
•
Rate
is a variable/constant (0–255) that specifies the number of
cycles between autorepeats. The rate is expressed in cycles of the
Button routine.
•
Bytevariable
is the workspace for Button. It must be cleared to 0
before being used by Button for the first time.
•
Targetstate
is a variable/constant (0 or 1) that specifies which
state the button should be in for a branch to occur. (0=not pressed,
1=pressed)
•
Address
is a label that specifies where to branch if the button is
in the target state.
Explanation
When you press a button or flip a switch, the contacts make or break a
connection. A brief (1 to 20-ms) burst of noise occurs as the contacts
scrape and bounce against each other. Button’s debounce feature
prevents this noise from being interpreted as more than one switch
action. (For a demonstration of switch bounce, see the demo program
for the Count instruction.)
Button also lets PBASIC react to a button press the way your computer
keyboard does to a key press. When you press a key, a character










