Alternative...
Just modify the include to suite your requirementCode:include "C:\PBP_PROG\INCLUDE_ROUTINES\KeyPad.bas" define OSC 20 DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1 DEFINE HSER_SPBRG 129 ' 9600 Baud @ 0.16% DEFINE HSER_CLROERR 1 ' Clear overflow automatically DEFINE KEYPAD_ROW 4 ' 4 ROW keypad DEFINE KEYPAD_ROW_PORT PORTB ' ROW port = PORTB DEFINE KEYPAD_ROW_BIT 0 ' ROW0 = PORTB.4 DEFINE KEYPAD_COL 4 ' 4 COL keypad DEFINE KEYPAD_COL_PORT PORTB ' COL port = PORTB DEFINE KEYPAD_COL_BIT 4 ' COL0 = PORTB.0 DEFINE KEYPAD_DEBOUNCEMS 200 ' debounce delay = 200 mSec DEFINE KEYPAD_AUTOREPEAT 1 ' use auto-repeat feature INTCON2.7=0 kKey var byte Start: @ READKEYPAD _kKey hserout ["Key=",dec kkey,13,10] goto start
kEYpAD.BAS... AVAILABLE BELLOW
http://www.picbasic.co.uk/forum/showthread.php?t=3250
and IN YOUR serout LINE...
AND now that some know you experiment a Write/Read/Modify behaviour... use your existing code but modify it likeCode:SEROUT serpin,N2400,[#key,#B0]'Send key value out PortA.1
What happen now ?Code:getkeyu:' Wait for all keys up LATB = 0 ' All output-pins low TRISB = $f0 ' Bottom 4-pins out, top 4-pins in @ nop IF ((PORTB >> 4) != $f) THEN getkeyu'If keys down, loop PAUSE 50 ' Debounce key-input getkeyp:' Wait for keypress FOR row = 0 TO 3 ' 4 rows in keypad LATB = 0 ' All output-pins low TRISB = (DCD row) ^ $ff ' Set one row pin to output @ nop col = PORTB >> 4 ' Read columns IF col != $f THEN gotkey' If any keydown, exit NEXT row GOTO getkeyp ' No keys down, go look again





Bookmarks