Chapter 9 keypad port – Remote Processing RPC-30 User Manual

Page 31

Advertising
background image

CHAPTER 9

KEYPAD PORT

RPC-30

Page 29

Figure 9-1 Keypad connector

INTRODUCTION

16 to 24 position keypads are plugged into keypad port
J5. K eys are a rran ged in a 4 x 4 to 4 x 6 matr ix form at.
A key is r ecognized when a r ow and a c olumn co nnect.

CAM BASIC automatically scans and debounces the
keypad every debounce time. D ebounce time is fixed at
80 ms. Keypad presses m ay be return ed either as a
number from 1 to 24 or as an ASCII character. The
ASCII character returned corr esponds to those on
Remote Processing' s KP-1 keypad. Character
assignments are changed using the SYS(8) function.

Keypads from Rem ote Processing simply plug into J5.

The keypad cable length should be limited to less than 5
feet.

If the keypad port is not used, it may be used as a
genera l purpose digital I/O port.

PROGRAMMING EXAMPLE

The following example sets up CAM BASIC to scan a 16
position keypad. The results are echo'ed to the display
and the speaker is sounded when a key is pressed.

20 'Optionally change keypad character 'B'
30 ' to the letter 'M'
40 POKE SYS(8)+7,77
50 CONFIG DISPLAY &50,7,1
60 ON KEYPAD$ GOSUB 500
70 DISPLAY (0,0)"Enter a number"

80 DISPLAY (1,0)
100 'loop for this example
110 GOTO 100

500 A$ = KEYPAD$(0)

510 IF A$ = "C" THEN ..clear_beep
520 IF A$ = "#" THEN ..enter
530 DISPLAY A$;
540 B$ = B$+A$
550 SOUND 600,.2
560 RETURN

600 ..clear_beep
610 B$=""
620 SOUND 600,.2
630 DELAY .4
640 SOUND 600,.2
650 DISPLAY (1,0) " ";
660 RETURN

700 ..enter
710 FL = 1
720 SOUND 800,.5
730 RETURN

Program explanation

Lines 10-80 set up the parameters for the keypad and
display. Line 80 positions the cursor on the next line.

Lines 500 to 730 process the key press. If a "C " or " #"
is pressed, it is an exception and is handled that way.
Otherwise, the character is displayed and stored. A beep
indicates it was saved.

Lines 600 to 660 send a do uble beep w hen data is
cleared. T he buffer (B$) is cleared as is the display.

Lines 700 to 730 process the "enter" key. A longer beep
is sounded and the enter fla g, F L, is set to a 1 to indicate
to another part of the p rogr am that B$ ha s complete
data.

The KEYPA D$(0) function returns a single character
string that has been assigned to a particular key. Keypad
p o si ti on s 17 - 24 d o n o t h a ve a ch a r ac t er a ss ig n ed to th e m .
These po sitions are as signed using the SYS(8) state ment.

KEYPAD PORT PINOUT - J5

The keypad port uses ports B and C from an 82C55.
Lowe r por t C is configu red as an input. Upper port C
and port B bits 0 and 1 are outputs. Port B bits are used
only when a 20 or 24 position keypad is installed.

Advertising