Shop OBEX P1 Docs P2 Docs Learn Events
help with lcd/keypad interface — Parallax Forums

help with lcd/keypad interface

argmafiaargmafia Posts: 30
edited 2006-03-02 00:40 in Learn with BlocklyProp
need some help with schematic and code for the interface of an LCD and keypad (a 4x20 serial lcd and a 4x4 keypad)

Thank you

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-03-01 15:21
    This should help: http://www.parallax.com/dl/docs/cols/nv/vol4/col/nv97.pdf

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • argmafiaargmafia Posts: 30
    edited 2006-03-01 17:17
    what if we have a serial lcd, what then?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-03-01 17:26
    No problem, just read the keyboard as shown in the article and send commands to your LCD on its own control pin (use the pin that was the LCD E line in the article). Easy.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • argmafiaargmafia Posts: 30
    edited 2006-03-01 19:41
    are we going to use the same code??? or what needs to be changed???
  • argmafiaargmafia Posts: 30
    edited 2006-03-01 19:46
    are we going to hook up all the wires(D0-D4 & data available) to the same LCD pin (pin E) in our serial LCD?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-03-01 20:07
    Just remove the LCD and related code from that project; and now that P0 is free (was the E line), use that to send serial commands to your LCD.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • argmafiaargmafia Posts: 30
    edited 2006-03-01 21:46
    But where do I connect the serial LCD and what code can I use?· Im sorry but I lack the programming ability and skills where maybe you could help me....
  • argmafiaargmafia Posts: 30
    edited 2006-03-01 21:53
    you think maybe u can show me a schematic of how to hook it up and write the code where the lcd interfaces with the keypad???
    thanks
  • argmafiaargmafia Posts: 30
    edited 2006-03-01 22:01
    We are trying this code but we are unable to get the correct responses on the debug window. Are we doing something wrong??
    Once I get the correct response, what commands do I need to send it to my LCD (initialization, baud rate... etc)?

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    ' ========================================================================================

    DIRL = %00001111 'p0 - p3 are outputs; p4-7 are inputs

    x VAR Byte

    DO
    GOSUB scan 'go to subroutine scan
    PAUSE 250 'pause for 250 ms
    DEBUG x, CR 'output x to the screen
    OUTA = 0 'set OUTA to be low
    LOOP

    scan: 'start of scan subroutine
    DO
    HIGH 0 'checking row one
    IF (IN4 = 1) THEN one
    IF (IN5 = 1) THEN two
    IF (IN6 = 1) THEN three
    IF (IN7 = 1) THEN A
    LOW 0

    HIGH 1 'checking row two
    IF (IN4 = 1) THEN four
    IF (IN5 = 1) THEN five
    IF (IN6 = 1) THEN six
    IF (IN7 = 1) THEN B
    LOW 1

    HIGH 2 'checking row three
    IF (IN4 = 1) THEN seven
    IF (IN5 = 1) THEN eight
    IF (IN6 = 1) THEN nine
    IF (IN7 = 1) THEN C
    LOW 2

    HIGH 3 'checking row four
    IF (IN4 = 1) THEN asterisk
    IF (IN5 = 1) THEN zero
    IF (IN6 = 1) THEN pound
    IF (IN7 = 1) THEN D
    LOW 3
    LOOP

    one:
    x = 49 'ascii for 1
    RETURN

    two:
    x = 50 'ascii for 2
    RETURN

    three:
    x = 51 'ascii for 3
    RETURN

    A:
    x = 65 'ascii for A
    RETURN

    four:
    x = 52 'ascii for 4
    RETURN

    five:
    x = 53 'ascii for 5
    RETURN

    six:
    x = 54 'ascii for 6
    RETURN

    B:
    x = 66 'ascii for B
    RETURN

    seven:
    x = 55 'ascii for 7
    RETURN

    eight:
    x = 56 'ascii for 8
    RETURN

    nine:
    x = 57 'ascii for 9
    RETURN

    C:
    x = 67 'ascii for C
    RETURN

    asterisk:
    x = 42 'ascii for *
    RETURN

    zero:
    x = 48 'ascii for 0
    RETURN

    pound:
    x = 35 'ascii for #
    RETURN

    D:
    x = 68 'ascii for D
    RETURN
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-03-02 00:40
    · In your Row Checking subroutines you're Branching to other subroutines (one, two, A, B, and so on) and terminating those same using "RETURN".
    · Why?·
    · RETURN only works if the Branch is the result of a GOSUB (not a GOTO).· I'm not sure where you want it to go to once you Detect a Key press and then you fetch the ASCII code (as you are.)· At present, you are IF...THEN GOTO'ing (when you don't write GOTO, it's implied that way.)· You can IF..THEN...GOSUB, but you have to write the GOSUB command.
    · I suppose you could consider changing those RETURNs (e.g. GOTO Subr-Debug, or something.)

    *****
    Hope this Reply doesn't make me a Bad Guy.

    Post Edited (PJ Allen) : 3/2/2006 12:48:18 AM GMT
Sign In or Register to comment.