Rpbasic-52 programming guide, Keypad – Remote Processing BASIC 52 User Manual

Page 69

Advertising
background image

RPBASIC-52 PROGRAMMING GUIDE

2-50

KEYPAD

Syntax:

A = K E Y P A D (function)
Where: function = 0 or 1

0 = return keypad position pressed from buffer
1 = returns number of keys in buffer

Function:

Returns key pad pressed po sition or numb er of keys in keyp ad buffer.

Mode:

Comm and, Run

Use:

A = KEY PAD(0) Returns a keypad position

Cards:

All

D E S C R IP T I ON

The keypad is automatically scanned, debounced, and placed in an 8 position buffer in the background. Key
presses are buffered until retrieved by the KEYPAD(0) function. Keypad positions are returned as a number
from 1 to 24. W hen a 0 is returned , there are no m ore keys in the bu ffer.

Position numbers 1 - 4 correspond to the top row while positions 12 - 16 are the bottom row of keys on the
KP-1 and KP-3 keypads. Thus, the letter 'B' on the KP-1 corresponds to position 8.

Use CL EAR KEY PAD to remove a ll characters from the buffer.

ON KE YPAD branches to a subroutine when a key is pressed. (check card for availability)

RELATED

C L E A R K E Y P A D , O N K E Y P A D

E R R O R

B A D D A T A

When function is out of range.

EXAMPLE

The following program prints out the keypad position as a key is pressed.

10 CLEAR KEYPAD
20 DO
30 UNTIL KEYPAD(1) = 1
40 PRINT KEYPAD(0)
50 GOTO 20

Advertising