Shop OBEX P1 Docs P2 Docs Learn Events
lcd with keypad control — Parallax Forums

lcd with keypad control

GiuseppeGiuseppe Posts: 51
edited 2009-06-21 04:34 in BASIC Stamp
I recently purchased a 2 x 16 lcd display that can support a 4 x 4 matrix keypad or 8 separate buttons. I have been reading the data sheet on http://www.web4robot.com/files/SerialLCDCtrl.pdf on it and it is pretty straight forward. The thing that I am actually having trouble with is the keypad chapter. I was planning on using 8 separate buttons. The readkeypad command says "This command sends a request for keypad data. The LCD module will return 1 byte keypad data. If there is no key data in the keypad buffer, 0 is returned. If there is key data, a key code from 0x01 to 0x10 is returned, depending on what key was pressed." My question is where does it return it too? Does it get dumped into a variable by using a SERIN command? Or does it just simply display it on the lcd? Or perhaps I am interpreting this completely wrong. If anybody has example code on the keypad interface on this particular lcd or has a better idea of what the manual is actually saying, it would be greatly appreciated! tongue.gif Thanks!

Comments

  • Clock LoopClock Loop Posts: 2,069
    edited 2009-06-05 09:15
    im assuming your using a BS2 microcontroller?

    This is not a parallax lcd/keypad so you won't find any bs2 programs for this device unless someone has written code for it.

    But it looks like once you have connected up an external keypad, you have to send the command that tells it what you have hooked up to the keypad pins.
    You need to send mode – 1 8 separate buttons.
    i.e the serout command combined with "0xFE 0x1C [noparse][[/noparse]Mode] " (but this hex is probably mode 0)

    Then you need to do a read keypad data.
    "The LCD module will return 1 byte "
    That is done by sending the lcd a command over serial. Then about 0.5 to 5 ms later you will get a reply via serial that will tell you which button was pressed.

    So you will need to do a serout, and specifiy "Syntax hexadecimal 0xFE 0x1B" once you send that to the keypad, immediately, you need to do a serin, the data will then be in the variable you specified with the serin command.
    If this is over your head, you might want to start out with something eaiser to program,
    to get familiar with the basic language.


    FROM THE DATASHEET:

    3.4 Keypad Commands.

    The module includes 8 bits digital port. This port can be programmed to connect the 4x4 matrix
    keypad, 8 separate buttons or 8 digital inputs/outputs.

    Set Keypad Mode
    Syntax hexadecimal 0xFE 0x1C [noparse][[/noparse]Mode]

    Description: This command initializes the digital port mode.
    Mode – 0 matrix keypad
    Mode – 1 8 separate buttons
    Mode – 2 8 digital inputs
    Mode – 3 8 digital outputs
    Default: Mode=0 (matrix keypad) after power up or reset.

    The matrix keypad of up to 16 keys (4 rows by 4 columns) or 8 separate buttons can be
    connected to the module. Each time a key is pressed, a key code from 1 (0x01) to 16 (0x10) is
    added to module keypad buffer and interface connector pin INT is pulled low. The keypad buffer
    can be read via Read Keypad Command. If INT signal is not used, the LCD module has to be
    polled to see if it has any keypad data available.
    NOTE: Each time a key is pressed, INT signal is pulled low, after the Read Keypad Command the
    INT signal goes to a high level.

    Read Keypad
    Syntax hexadecimal 0xFE 0x1B

    Description: This command sends a request for keypad data. The LCD module will return 1 byte
    keypad data. If there is no key data in the keypad buffer, 0 is returned. If there is key data, a key
    code from 0x01 to 0x10 is returned, depending on what key was pressed.
    NOTE: LCD controller needs from 0.5 to 5 ms (depending on the communication speed) to
    transmit the data byte; therefore, the subsequent input must have an appropriate delay.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Meh. Nothing here, move along.
  • GiuseppeGiuseppe Posts: 51
    edited 2009-06-06 01:00
    Ah okay. I was thinking that but I did not expect that a serin command would catch the returned data in time. I just got the LCD today in the mail and will probably tinker with it after work tomorrow. I'll tell ya how the keypad goes. Thanks.
  • GiuseppeGiuseppe Posts: 51
    edited 2009-06-21 04:34
    finally got a chance to do it. been very busy. works like a charm. thanks!
Sign In or Register to comment.