PDA

View Full Version : 3x4 keypad picbasicpro



gkahraman82
- 29th May 2006, 21:49
ı wanna make 3x4 keypad LCD project by using picbasicpro . I success to make 4x4 keypad.ı could not success to make 3x4 keypad project. I use this project belove. When ı run the circuit always number "5" is given to LCD. I cant understand why it is like that. This is the code. Is it true ???????

1st column - RB0
2nd column - RB1
3rd column - RB2
1st row - RB3
2nd row - RB4
3rd row - RB5
4th row - RB6


DEFINE LOADER_USED 1
i VAR byte
col VAR byte
row VAR byte
num VAR byte
PIN VAR byte[4]
ADMIN VAR byte[4]
GREEN VAR PORTA.2
YELLOW VAR PORTA.1
BUZZER VAR PORTA.3
OPTION_REG.7 = 0


KEYPAD:
PAUSE 50

NO_KEY:
TRISB = %01111000
PORTB = 0
IF ((PORTB >> 3)!= %1111)THEN GOTO NO_KEY
PAUSE 50

GOTKEY:
FOR col = 0 to 2
row = 0 TRISB = (dcd col)^%11111111
PORTB = 1
row = PORTB>>3
IF (row!= %1111)THEN CAL_NUM
NEXT col
GOTO GOTKEY

CAL_NUM:
PAUSE 500
num = (col*3) + (ncd (row^$F))
RETURN
Please tell me what changes do i have to make to this program.
Thanks a million!!!