KEYPAD PORT
INTRODUCTION
16, 20, or 24 position keypads are plugged into keypad port J5. Keys are arra nged in a m atrix for mat. A key is recogn ized whe n a row and a colum n connect.
Keypad presses are multi- tasked using ON KEYPAD . When a key is pressed, the program br anches to the subroutine.
Keypads from Rem ote Processing simply plug into J5. The keypad cable length should be limited to less than 5 feet.
Figure 9-1 Keypad connector
PROGRAMMING EXAMPLE
The following example sets up RPBASIC to scan a 16 position keypa d. T he results a re echo ' ed when a key is pressed. Press the 'D' key to enter .
SECTION 9
10 STRING 200,20
20 $(0) = "123A456B789C*0#D"
30 P = 1
40 PF = 0
50 PRINT "Enter a number from the keypad",
REM Rest of program continues
REM Scan keypad and update display
200 GOSUB 500
210 IF PF = 0 THEN 200
220 PRINT
230 PRINT "Entered string is: ",$(2)
240 PF = 0
250 GOTO 50
500 A = KEYPAD(0)
510 IF A = 0 THEN 500
520 IF A = 12 THEN 600 : REM Process clear
530 IF A = 16 then 700 : REM process enter
540A=ASC($(0),A)
550PRINT CHR(A),
560ASC($(2),P) = A
570P = P + 1
580ASC($(2),P) = 13
590RETURN
600REM Clear input string
610$(2) = ""
620P = 1
630RETURN
700REM Enter processing
710P = 1
720PF = 1
730RETURN
Program explanation
Line 20 defines the keypad legend. Letters may be redefined as necessary.
Line 30 sets the position counter used to insert characters into the string.
Line 200 w aits for a ke y press. The enter ed string is printed.
Line 500 checks the keypad. If a character is available, it processe s it.
Lines
Page