Positron Compiler Documentation

Inkey

Positron8 · Revision 4.0.6.5 · PDF page 156

Variable = Inkey

Scan a keypad and place the returned value into variable

Variable is a user defined variable

Dim bVar1 as Byte

bVar1 = Inkey          ' Scan the keypad
DelayMs 50             ' Debounce by waiting 50ms
Print Dec bVar1, " "   ' Display the result on the LCD

Inkey will return a value between 0 and 16. If no key is pressed, the value returned is 16.

Using a LookUp command, the returned values can be re-arranged to correspond with the legends printed on the keypad: -

bVar1 = Inkey
bKey = LookUp bVar1, [255,1,4,7,"*",2,5,8,0,3,6,9,"#",0,0,0]

The above example is only a demonstration, the values inside the LookUp command will need to be re-arranged for the type of keypad used, and its connection configuration.

Declare for Inkey

Declare Keypad_Port Port Assigns the Port that the keypad is attached to.

The keypad routine requires pull-up resistors, therefore, the best Port for this device is PORTB, which comes equipped with internal pull-ups. If the Declare is not used in the program, then

Original diagram or table from Positron8, PDF page 156
Original figure / layout · PDF page 156
Text in this figure or table

+5 Volts Port.

R1

The diagram illustrates a4.7k14
VDD13
typical connection of aRB7
412
MCLRRB6
12-button keypad to a11
RB5R2-R5
C1C210
4MHzRB4470

PIC16F84. If a 16-button

10uf0.1uf9
123
CrystalRB3
168

type is used, then COL-

OSC1 RB2

7 RB1

UMN 4 will connect to 6

R

RB0 4 5 6

O

PORTB.7 (RB7).PIC16F84
3W

RA4

152
789S
OSC2RA3
C3C41

RA2 18

22pf 22pf

RA1 17

RA0 0 #

VSS * 5

0v COLUMNS

PORTB is the default

View original PDF page 156Open page in PDFOriginal PDF page 156