Using a PIC to program keypad?

Discussion in 'Programmer's Corner' started by dooddyman, Nov 5, 2013.

  1. dooddyman

    Thread Starter New Member

    Nov 5, 2013

    I was learning PIC BASIC language along with assembly, then I came up to a project which requires inputs of external keypad and the aim is to change the state of a particular port when 4 subsequent inputs of the keypad matches with the programmed.

    In short, a lock system with 4 number password. Also in the project it asks to "inform" whether or the numbers pressed were correct or not.

    Do you have any suggestions? I just have got blank trying to think how to make the computer realize that certain number matches certain bits.

    Please help me on this one!

    Thank you
  2. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    Hi doodyman (hope you're not Arabic?!). :)

    It helps to draw out a flowchart, in a paint program or just on paper. This lets you create a procedure, simple and neat, without code writing getting in the way and confusing you. Once you know exactly what the proedure is, writing the code gets easy.

    Maybe a procedure a bit like this (psuedo code);
    Code ( (Unknown Language)):
    2. if(new key is received)
    3. {
    4.   //first move previous inputs down
    5.   d = c
    6.   c = b
    7.   b = a
    8.   // add in new key
    9.   a = new_key
    10.   // test for a match
    11.   if(a=='h' && b=='e' && c=='l' && d=='p') openlock()
    12. }
    your flowchart procedure might also include a timeout period, or safety lockout after a bad 4digit code is entered etc.
  3. Art

    AAC Fanatic!

    Sep 10, 2007
    I think that means being stuck on the actual keypad scan routine
    (ie looking at bits on ports),
    but there are so many tutorials dealing with interfacing a pic with a keypad,
    I don't think it could be made any easier.