Shop OBEX P1 Docs P2 Docs Learn Events
store numbers from keypad — Parallax Forums

store numbers from keypad

WhipeOutWhipeOut Posts: 13
edited 2005-04-15 20:07 in BASIC Stamp
I'm working on this pin code project, but I'm having some problems keeping the input data.

I'm using the SERIN command to get data from the keypad through a 4x20 LCD display.

I'd like to write a 4 digit pin code to the eeprom at the beginning of the program and name it pin_code or something (eks 1234)
Then I'd like to store the 4 digit input from the keypad as, let's say, pin_entered.

IF pin_code = pin_entered THEN granted

You get the point?

How can this be done??

Thanks..

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-04-14 10:06
    WhipeOut -

    Play around with this rudimentary and incomplete program.

    Saved_Pin var Byte(4)

    Saved_Pin(0) = 1 'First digit of valid pin
    Saved_Pin(1) = 2 'Second digit of valid pin
    Saved_Pin(2) = 3 'Third digit of valid pin
    Saved_Pin(3) = 4 'Fourth digit of valid pin

    Pin_Number var byte(4)
    SERIN PIN_NUMBER\4

    For n =·0 to 3

    IF Saved_Pin(n) = Pin_Number(n) then Next_Pin

    Go to Bad_Pin

    Next_Pin: Next

    Pin_Okay:
    .....

    Bad_Pin:
    ----

    END

    Regards,

    Bruce Bates

    Post Edited (Bruce Bates) : 4/15/2005 5:23:27 AM GMT
  • WhipeOutWhipeOut Posts: 13
    edited 2005-04-14 10:49
    Thanks... I'll try this one... [noparse];)[/noparse]
  • WhipeOutWhipeOut Posts: 13
    edited 2005-04-14 21:31
    Wouldn't it be easy to breake this PIN if you'd have to match the first digit to continue??
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-04-15 05:21
    WhipeOut -

    As I said "play around with this rudimentary and incomplete program". If you want to make it more secure you can change it any way you choose to. The person entering the pin must enter all 4 digits, so they have no idea when or where the comparison failed.

    PGP that brief routine is NOT! smile.gif

    I did make some changes to the original routine, however, to correct an array positioning error.

    Bruce
  • Beau SchwabeBeau Schwabe Posts: 6,557
    edited 2005-04-15 05:40
    Just to offer another approach I have used with writing my own screen savers...

    If you had a "fixed" buffer of a specific width i.e 4 digits, simply roll out the last digit and roll in the new digit.
    When the equivalent of "ENTER" had been pressed compare what is in the buffer.


    Initialize:
    Saved_Pin var Byte(4)
    
    MainLoop:
    {Detect Key Press here and Jump to KeyPressed}
    goto MainLoop
    
    KeyPressed:
    {If NewKey = "ENTER" then Jump to CodeTest}
    Saved_Pin(4) = Saved_Pin(3)
    Saved_Pin(3) = Saved_Pin(2)
    Saved_Pin(2) = Saved_Pin(1)
    Saved_Pin(1) = NewKey
    
    KeyRelease:
    {Detect Key Release here and Jump to MainLoop}  
    goto KeyRelease
    
    CodeTest:
    {Compare Buffer to valid codes and do something here from the comparison}
    goto MainLoop
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe - Mask Designer III

    National Semiconductor Corporation
    Latest Company News
    (Communication Interface Division)
    500 Pinnacle Court, Suite 525
    Mail Stop GA1
    Norcross,GA 30071
  • WhipeOutWhipeOut Posts: 13
    edited 2005-04-15 20:07
    Thanks guys...
    I'll check the functionality when it's time.

    Thanks
Sign In or Register to comment.