27220 Parallax Inc, 27220 Datasheet - Page 105

BOOK STAMPWORKS

27220

Manufacturer Part Number
27220
Description
BOOK STAMPWORKS
Manufacturer
Parallax Inc
Datasheet

Specifications of 27220

Accessory Type
Booklet
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
StampWorks
Lead Free Status / RoHS Status
Lead free / RoHS Compliant, Not applicable / Not applicable
Program: SW21-EX14-Debounce.BS2
' {$STAMP BS2}
' {$PBASIC 2.5}
' -----[ Program Description ]---------------------------------------------
'
' This program demonstrates the simultaneous debouncing of multiple inputs.
' The input subroutine is easily adjusted to handle any number of inputs.
' -----[ I/O Definitions ]-------------------------------------------------
BtnBus
' -----[ Variables ]-------------------------------------------------------
btns
idx
' -----[ Program Code ]----------------------------------------------------
Main:
' -----[ Subroutines ]-----------------------------------------------------
Get_Buttons:
Behind the Scenes
When debouncing only one input, the BASIC Stamp’s BUTTON instruction works
perfectly well and even adds a couple of useful features (like auto-repeat). To
debounce two or more inputs, however, we need to create a bit of code. The
DO
LOOP
btns = %1111
FOR idx = 1 TO 5
NEXT
RETURN
GOSUB Get_Buttons
DEBUG HOME,
PAUSE 50
btns = btns & ~BtnBus
PAUSE 5
"Inputs = ", IBIN4 btns
VAR
VAR
VAR
INA
Nib
Nib
' four inputs, pins 0 - 3
' debounced inputs
' loop counter
' get debounced inputs
' display in binary mode
' enable all four inputs
' test inputs
' delay between tests

Related parts for 27220