4x4 keypad Help


Closed Thread
Results 1 to 7 of 7

Thread: 4x4 keypad Help

Hybrid View

  1. #1
    Join Date
    Apr 2008
    Posts
    3


    Did you find this post helpful? Yes | No

    Question

    Thank mister_e for your reply
    i am a bit confused by what you mean by

    just the wrong way

    Also without doing anything else to the program apart from changing the Enable PORTB pullups line when i used a 16f877a

    ================================================== =
    OPTION_REG.7 = 0 ' Enable PORTB pullups for 16f877a
    'INTCON2.7 = 1 ' Enable PORTB pullups for 18f452
    ================================================== =

    the program works fine could it be my pic?

    Best Regards
    Sabu

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    In your first post you used...
    INTCON2.7=1

    But this actually DISABLE the internal pull-up...

    Use
    INTCON2.7=0
    instead, and the problem will disapear
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Apr 2008
    Posts
    3


    Did you find this post helpful? Yes | No

    Default

    Oops silly me
    it works fine

    thanks a lot

    Sabu

  4. #4
    andymarrole's Avatar
    andymarrole Guest


    Did you find this post helpful? Yes | No

    Default warning unable to include keypas.bas and lcd.bas

    i using pic18f4550 and PICBASIC PRO version 1.0 as my compiler..
    while i compile my program below, there is warning which is

    unable to include file keypad.bas
    unable to include file lcd.bas..

    this is my source code...
    Code:
    '****************************************************************
    '*  Name    : UNTITLED.BAS                                      *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2010 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 10/5/2010                                         *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    Include "modedefs.bas" 
    
    DEFINE PIC18F4550
    DEFINE OSC 4
    
    
    INCLUDE "KeyPad.bas" ' ( mister_e 's great keypad include file )
    INCLUDE "lcd.bas"  
    CMCON = 7
    ADCON1 = 7
      
              
    TRISD  = %00000000
    TRISB  = %11111111
                 
    '// Declare Variables...
    Col_A     VAR PORTB.0
    Col_B     VAR PORTB.1
    Col_C     VAR PORTB.2
    Col_D     VAR PORTB.3
    Row_A     VAR PORTB.4
    Row_B     VAR PORTB.5
    Row_C     VAR PORTB.6
    Row_D     VAR PORTB.7
    
    
    
    Scan_Col  VAR BYTE       ' Counter - current col  
    Key_Press VAR BYTE       ' Value of key (0-9) & * + # + A + B + C + D
    Key_Down  VAR BYTE       ' Flag set true when key is depressed
    Allow_Key VAR BYTE       ' Flag - disallow multiple keys being pressed
    I         VAR byte       ' General working var
    
    Scan_Keypad:
    
      @ incf _Scan_Col, 1   ' Inc col pos...
    
      SELECT CASE Scan_Col  ' Col (1-4)
             
             CASE 1
                  Col_A = 0 ' Switch on col (active low)    
                  Col_B = 1 ' Col off    
                  Col_C = 1 ' Col off 
              Col_D = 1 ' Col off
                           
                  '// 1 Key
                           IF Row_A = 0 THEN        ' Key down? ... 
                              IF Allow_Key = 0 THEN ' Any other key down?
                                 Key_Press = 1      ' Load var w/value of key           
                                 Allow_Key = 1      ' Disallow other keys
                              ENDIF   
                           ENDIF                          
                  '// 4 Key
                           IF Row_B = 0 THEN
                              IF Allow_Key = 0 THEN 
                                 Key_Press = 4                 
                                 Allow_Key = 1
                              ENDIF   
                           ENDIF
                  '// 7 Key
                           IF Row_C = 0 THEN
                              IF Allow_Key = 0 THEN 
                                 Key_Press = 7                 
                                 Allow_Key = 1
                              ENDIF   
                           ENDIF
                  
    
            '// * Key
                           IF Row_D = 0 THEN
                              IF Allow_Key = 0 THEN 
                                 Key_Press = 42                 
                                 Allow_Key = 1
                              ENDIF   
                           ENDIF
                  
             CASE 2
                  Col_A = 1    
                  Col_B = 0    
                  Col_C = 1 
                  Col_D = 1    
                           
                  '// 2 Key
                           IF Row_A = 0 THEN
                              IF Allow_Key = 0 THEN 
                                 Key_Press = 2                 
                                 Allow_Key = 1
                              ENDIF   
                           ENDIF
                  '// 5 Key
                           IF Row_B = 0 THEN
                              IF Allow_Key = 0 THEN 
                                 Key_Press = 5                 
                                 Allow_Key = 1
                              ENDIF   
                           ENDIF
                  '// 8 Key 
                           IF Row_C = 0 THEN
                              IF Allow_Key = 0 THEN 
                                 Key_Press = 8                 
                                 Allow_Key = 1
                              ENDIF   
                           ENDIF
                  '// 0 Key
                           IF Row_D = 0 THEN
                              IF Allow_Key = 0 THEN 
                                 Key_Press = 0                 
                                 Allow_Key = 1
                              ENDIF   
                           ENDIF
    
             CASE 3
                  Col_A = 1     
                  Col_B = 1     
                  Col_C = 0
                  Col_D = 1
    
                  '// 3 Key
                           IF Row_A = 0 THEN
                              IF Allow_Key = 0 THEN 
                                 Key_Press = 3                 
                                 Allow_Key = 1
                              ENDIF   
                           ENDIF
                  '// 6 Key
                           IF Row_B = 0 THEN
                              IF Allow_Key = 0 THEN 
                                 Key_Press = 6                 
                                 Allow_Key = 1
                              ENDIF   
                           ENDIF
                   '// 9 Key
                          IF Row_C = 0 THEN
                              IF Allow_Key = 0 THEN 
                                 Key_Press = 9                 
                                 Allow_Key = 1
                              ENDIF   
                           ENDIF
                  '// # Key
                           IF Row_D = 0 THEN
                              IF Allow_Key = 0 THEN 
                                 Key_Press = 35                 
                                 Allow_Key = 1
                              ENDIF   
                           ENDIF
    
    
             CASE 4
                  Col_A = 1     
                  Col_B = 1     
                  Col_C = 1
                  Col_D = 0
    
                  '// A Key
                           IF Row_A = 0 THEN
                              IF Allow_Key = 0 THEN 
                                 Key_Press = 65                 
                                 Allow_Key = 1
                              ENDIF   
                           ENDIF
                  '// B Key
                           IF Row_B = 0 THEN
                              IF Allow_Key = 0 THEN 
                                 Key_Press = 66                 
                                 Allow_Key = 1
                              ENDIF   
                           ENDIF
                   '// C Key
                          IF Row_C = 0 THEN
                              IF Allow_Key = 0 THEN 
                                 Key_Press = 67                 
                                 Allow_Key = 1
                              ENDIF   
                           ENDIF
                  '// D Key
                           IF Row_D = 0 THEN
                              IF Allow_Key = 0 THEN 
                                 Key_Press = 68                
                                 Allow_Key = 1
                              ENDIF   
                           ENDIF
    
    
                  Scan_Col = 0   
    END SELECT
    
    
    LCDOUT $fe,1
     LCDOUT " Key_Press "
    
    
    
    
    
    '// Check for key release, all cols on (active low) ...
    Col_A = 0     
    Col_B = 0     
    Col_C = 0
    Col_D = 0
    
    IF Row_A = 1 THEN
      IF Row_B = 1 THEN
         IF Row_C = 1 THEN
            IF Row_D = 1 THEN
               Allow_Key = 0
               Key_Down = 0
               Key_Press = 255
            ENDIF
         ENDIF
      ENDIF
    ENDIF
               
    GOTO Scan_Keypad

    please help me...
    thank you...

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default

    Hi,
    Do you have those two files, KeyPad.bas and lcd.bas in the same folder as your source file that you're trying to compile?

    With that said, PBP1.0 sounds REALLY old, are you sure that is the cirrect version. And lastly, there's really no need to post the same question in three different threads, one would've been enough.

    /Henrik.

Similar Threads

  1. connecting a 4X4 keypad
    By fadibasic in forum Schematics
    Replies: 6
    Last Post: - 12th November 2008, 17:52
  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. 4x4 Keypad and LCD sharing port B
    By msnm4 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 9th May 2008, 08:13
  4. I2C PCF8574 4X4 Keypad routine
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th January 2007, 21:25
  5. Inconsistent output on a 4x4 matrix keypad
    By markcadcam in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 24th November 2006, 03:54

Members who have read this thread : 0

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