Combinaton Gate access


Results 1 to 40 of 48

Threaded View

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


    Did you find this post helpful? Yes | No

    Default

    tons of different way to do it. You could even set your secret code in an array, read the keypad x times, compare the result with the array.

    i'll try something.. maybe this will put some lights...
    Code:
            '                      
            '       Hardware assignment
            '       ====================
                    '
                    '   System LCD
                    '   -----------
            DEFINE LCD_DREG PORTD     ' LCD data port 
            DEFINE LCD_DBIT 4         ' LCD data starting bit 0 or 4 
            DEFINE LCD_RSREG PORTD    ' LCD register select port 
            DEFINE LCD_RSBIT 2        ' LCD register select bit 
            DEFINE LCD_EREG PORTD     ' LCD enable port 
            DEFINE LCD_EBIT 3         ' LCD enable bit 
            DEFINE LCD_BITS 4         ' LCD bus size 4 or 8 
            DEFINE LCD_LINES 2        ' Number lines on LCD 
            DEFINE LCD_COMMANDUS 2000 ' Command delay time in us 
            DEFINE LCD_DATAUS 50      ' Data delay time in us     
    
                    '
                    '   4X4 matrix Keypad
                    '   -----------------
            include "c:\PBP_PROG\Include_Routines\keypad.bas"
            DEFINE KEYPAD_ROW        4        ' 4 ROW keypad       
            DEFINE KEYPAD_ROW_PORT   PORTB    ' ROW port = PORTB
            DEFINE KEYPAD_ROW_BIT    4        ' ROW0 = PORTB.4
            DEFINE KEYPAD_COL        4        ' 4 COL keypad
            DEFINE KEYPAD_COL_PORT   PORTB    ' COL port = PORTB
            DEFINE KEYPAD_COL_BIT    0        ' COL0 = PORTB.0
            DEFINE KEYPAD_DEBOUNCEMS 100      ' debounce delay = 100 mSec
        
            '   
            '       Variables definition 
            '       ===================
            SecretCode          var byte[5]
            CounterA            var byte
            Match               var byte
        
            '
            '       Software/Hardware initialisation
            '       ================================
            secretcode[0]=1
            secretcode[1]=2
            secretcode[2]=3
            secretcode[3]=4
            secretcode[4]=5
            
            '
            '       Program start
            '       =============
    Start:
            match=0
            lcdout $FE,1,"Enter the code"
            for countera = 0 to 4
                @   READKEYPAD _Key
                if Key=secretcode[countera] then Match=Match+1
                lcdout $FE,($C0+COUNTERA),"*"
                next
    
            if match=5 then
                lcdout $FE,1,"Access Granted!"
                else
                    lcdout $FE,1,"Access denied..."
                endif
    
            PAUSE 2000
            goto start
    to answer your original question... your code don't work because you don't keep track of your user entry. So it always stick to the first character => 7

    and this...
    Code:
        If ByteA = 4  then ByteA = "A"
        if ByteA = 5  then ByteA = 4
        if ByteA = 6  then ByteA = 5
        if ByteA = 7  then ByteA = 6
        if ByteA = 8  then ByteA = "B"
        if ByteA = 9  then ByteA = 7
        if ByteA = 10 then ByteA = 8
        if ByteA = 11 then ByteA = 9
        if ByteA = 12 then ByteA = "C"
        if ByteA = 13 then ByteA = "*"
        if ByteA = 14 then ByteA = 0
        if ByteA = 15 then ByteA = "#"
        if ByteA = 16 then ByteA = "D"
    could be replace by the single line bellow.
    Code:
    LOOKUP ByteA,[0,1,2,3,"A",4,5,6,"B",7,8,9,"C","*",0,"#","D"],ByteA
    Or store the table in the EEPROM, then read from it..
    Code:
    DATA @1,1,2,3,"A",4,5,6,"B",7,8,9,"C","*",0,"#","D"
    '
    '
    '
    '
    '
    Read ByteA, ByteA
    Last edited by mister_e; - 11th February 2007 at 11:46.
    Steve

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

Similar Threads

  1. A logic gate chip with 1 ea XOR and 2 ea AND gates?
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 21
    Last Post: - 5th August 2009, 05:29
  2. Access to sim memu
    By sahin5002 in forum GSM
    Replies: 2
    Last Post: - 16th June 2009, 11:57
  3. truck gate
    By Melros in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 13th October 2007, 13:23
  4. 18f2550 'access is denied' USB error?
    By Giulio in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 30th December 2006, 14:29
  5. FYI - How to Access individual bytes in Word Arrays
    By Melanie in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 20th July 2003, 21:56

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