help! pic 16f84a!

Discussion in 'Embedded Systems and Microcontrollers' started by habarabadabas, Aug 21, 2014.

  1. habarabadabas

    Thread Starter New Member

    Apr 16, 2014
    6
    0
    good day guys.. im just wondering, how do you make a code to enable a 3.input password, wherein it requires you to input the codes correctly, in the correct order. whenever you failed to input the password correctly, an LED will blink. note that im using a pic16f84a and, assembly language just isnt my kind of thing. any replies would be greatly appreciated..
     
  2. ericgibbs

    AAC Fanatic!

    Jan 29, 2010
    2,503
    380
    hi,
    If you post your attempt of the assembly code listing, I will look thru it.
    E
     
  3. habarabadabas

    Thread Starter New Member

    Apr 16, 2014
    6
    0
    Here is my problem sir, my code neglects the order of however you enter the password.
    Pressing 1-2-3, activates "kr", the special function. Pressing 1-2-4-5-1-2-3, 1-2-1-3, 2-1-2-3 etc, as long as 1-2-3 is entered in order, the special function still activates. Could you please look into it. I would be very grateful..

    I need it to function like whenever you enter the wrong combination, like 1-4-2, it would activate an error function. :)


    View attachment CODE.txt
     
  4. ericgibbs

    AAC Fanatic!

    Jan 29, 2010
    2,503
    380
    hi,
    The code is not for a 16F84A.??
    The following are Reserved locations for SFR's.??, not code.

    Code ( (Unknown Language)):
    1.  
    2. DCNT0    equ    h'07'
    3. DCNT1    equ    h'08'
    4. DCNT2    equ    h'09'
    5. DCNT3    equ    h'10'
    6.  
    7. KCNT0    equ    h'11'
    8. KCNT1    equ    h'12'
    9. KCNT2    equ    h'13'
    10. KCNT3    equ    h'14'
    11.  
    12. KRPASS0    equ    H'05'
    13.  
    14.  
     
  5. habarabadabas

    Thread Starter New Member

    Apr 16, 2014
    6
    0
    hmmm last time we compiled the code it worked; the passcode being 1-2-3 at any order.
    I was wondering what to do with the KRPW0-KPRW1 to make the passcode work in the order 1-2-3, without pressing any other keys.
     
  6. ericgibbs

    AAC Fanatic!

    Jan 29, 2010
    2,503
    380
    hi,
    Your code waits for PORT0,1,2 to be switched Hi and Lo in the correct sequence OK.

    What do you expect this KR code to do,??

    Code ( (Unknown Language)):
    1.  
    2. KR  MOVLW    b'10000000'
    3.     MOVWF    h'06'
    4. KL0    MOVLW    d'7'
    5.     MOVWF    KCNT0
    6. KL1    CALL    DELAY1
    7.     BCF    h'03', 0
    8.     RRF    h'06', F
    9.     DECFSZ    KCNT0, F
    10.     GOTO    KL1
    11.     MOVLW    d'7'
    12.     MOVWF    KCNT0
    13. KL2    CALL    DELAY1
    14.     BCF    h'03', 0
    15.     RLF    h'06', F
    16.     DECFSZ    KCNT0, F
    17.     GOTO    KL2
    18.     GOTO    KL0
    19.  
     
  7. habarabadabas

    Thread Starter New Member

    Apr 16, 2014
    6
    0
    oh, thats when the connected LEDs start to blink from the left to the right then vice versa. the PW should be pressed for the LEDs to blink.
     
  8. ericgibbs

    AAC Fanatic!

    Jan 29, 2010
    2,503
    380
    hi,
    After switching PORTA,0,1,2 in sequence, PORTB cycles thru 0,...7 and 7... 0 continuously.
    Thus zip file contains a screen shot AVI file , use Windows Media to view.

    E
     
  9. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    You need to change the code so that in the three sections waiting for a keypress, they look for any keypress, then check if it is the right one. But then you will have another problem because in the few microseconds it takes to get to the second function the key will still be pressed. So in between checking for each press you need to check for the key (all keys?) being released. But then you have another problem because keys bounce, so add a short (20ms) delay after keys are released while checking that they stay released.
    While testing these things it is handy to light a different LED to indicate which stage you are at.
     
  10. nigelwright7557

    Senior Member

    May 10, 2008
    487
    71
    Store the 3 key presses and only then look to see if they are correct.
    If 4 keys are pressed reset all 3 stored codes.
     
Loading...