I made a simple schematic for testing my remote control stalk near the steering wheel, from Renault.
I use "KeyPad_2.bas" , addapted to my hardware :
Code:
;
; Default settings
; ================
KB_ROW = 2 ; 2 ROW keypad
KB_ROW_PORT = PORTB ; Keypad ROW on PORTB
KB_ROW_BIT = 0 ; ROW0 = PORTB.0
KB_COL = 3 ; 3 COL keypad
KB_COL_PORT = PORTA ; Keypad Col on PORTA
KB_COL_BIT = 0 ; COL0 = PORTA.0
DebounceDelay = 0x41 ; debounce delay 41mSec
SINGLE_SCAN = 0 ; Scan ;till a key is pressed
KEYPAD_AUTOREPEAT = 1
The code it's verry simple :
Code:
@ DEVICE pic16F628A, XT_OSC, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_OFF, LVP_OFF
Define OSC 4 ' 4MHz
CMCON = 7 ' Disable on-chip comparator, PORTA in digital mode
OPTION_REG.7=1
include "c:\pbp\MYKEY.BAS" ' see http://www.picbasic.co.uk/forum/showthread.php?t=3250
main:
gosub keypadscan
gosub check
goto main
check:
select case key
CASE 1
portb.2 = 1
pause 5000
portb.2 = 0
case 2
portb.3 = 1
pause 5000
portb.3 = 0
case 3
portb.4 = 1
pause 5000
portb.4 = 0
case 4
portb.5 = 1
pause 5000
portb.5 = 0
case 5
portb.6 = 1
pause 5000
portb.6 = 0
case 6 ; track +
portb.7 = 1
pause 5000
portb.7 = 0
end select
Return
But....
Allways LED's on PortB.2 and PortB.3 are ON ! What I am doing wrong ?!? Thanks in advance for reply !
Bookmarks