Matrix Keypad routine


Results 1 to 40 of 135

Threaded View

  1. #36
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default Re: Matrix Keypad routine

    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 !
    Attached Images Attached Images  

Similar Threads

  1. calculator-like code entry with matrix keypad and display
    By Dennis in forum mel PIC BASIC Pro
    Replies: 35
    Last Post: - 16th December 2009, 22:58
  2. Need help in matrix keypad coding
    By rano_zen06 in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 24th May 2008, 13:16
  3. I2C PCF8574 4X4 Keypad routine
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th January 2007, 21:25
  4. Inconsistent output on a 4x4 matrix keypad
    By markcadcam in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 24th November 2006, 03:54
  5. very basic matrix keypad question
    By kitcat in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 8th July 2006, 21:33

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts