help with lcd/keypad interface
argmafia
Posts: 30
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
Thank you
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
thanks
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
x = 68 'ascii for D
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