PDA

View Full Version : 3x4 keypad picbasicpro 2



gkahraman82
- 29th May 2006, 21:55
And also does anybody know 3x4 keypad picbasic code?

paulvits
- 30th May 2006, 08:12
Follow this link:http://www.rentron.com/PicBasic1.htm

I used the 4X4 keybord succesfully several times.
greetings,
Paul

mister_e
- 30th May 2006, 14:12
Another way,
http://www.picbasic.co.uk/forum/showthread.php?t=3250
allow you to use the keypad format you want. 3x4,3x5,6x8,8x8 .....

gkahraman82
- 30th May 2006, 17:07
can you convert this programme to 3x4 kaypad programme????? :(



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
DATA 0,..............??????? I don't know how to write this part!!!

SETPIN:
SETPIN:
i = 0 WHILE i<4 PIN = 0 GOSUB KEYPAD LET PIN = num i = i + 1
WEND

CHKAMD:
WRITE 1, PIN
PAUSE 200
READ 0, ADMIN
PAUSE 200
IF PIN4 = ADMIN THEN
GREEN = 1
END
ELSE
GOTO SETPIN
ENDIF
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:
YELLOW = 1
SOUND BUZZER,[100,10]
PAUSE 500
YELLOW = 0
num = (col*3) + (ncd (row^$F))
RETURN

mister_e
- 31st May 2006, 00:16
Using the link i provided and using MPASM to compile you need...

INCLUDE "KeyPad.bas"

DEFINE KEYPAD_ROW 4 ' 4 ROW keypad
DEFINE KEYPAD_ROW_PORT PORTB ' ROW port = PORTB
DEFINE KEYPAD_ROW_BIT 3 ' ROW0 = PORTB.3
DEFINE KEYPAD_COL 3 ' 3 COL keypad
DEFINE KEYPAD_COL_PORT PORTB ' COL port = PORTB
DEFINE KEYPAD_COL_BIT 0 ' COL0 = PORTB.0

YourVar var byte

Start:
@ READKEYPAD _YourVar
' plah plah
' plah plah
' plah plah
'

and your keypad results will be stor in YourVar variable as follow


col0 col1 col2
1 2 3 row0
4 5 6 row1
7 8 9 row2
10 11 12 row3