Programming help with keypad interfacing to the LCD
Gabe
Posts: 24
Hi Guys
I was wondering how do I get my LCD to output the word "Keypress" whenever a key is pressed on the Keypad that is interfaced to it. Everything I inserted seems to always get the whole thing stuck.
Here are my codes:
Subroutine keyScan basically scans for the keypress on the 4 x 4 matrix keypad and output the value on to the debug window. Any help appreciated.
Thanks in advance,
Gab
I was wondering how do I get my LCD to output the word "Keypress" whenever a key is pressed on the Keypad that is interfaced to it. Everything I inserted seems to always get the whole thing stuck.
Here are my codes:
DATA "Hello, This is the LCD." Initlcd: LCDCMD Lcd_pin,32 'sets lcd in 4 bit mode PAUSE 1000 FOR temp = 0 TO 2 LCDCMD 0,48 PAUSE 1 NEXT LCDCMD Lcd_pin,40 'sets lcd to 2 linemode with 5x8 font LCDCMD Lcd_pin,12 'turns on display with no cursor LCDCMD Lcd_pin,6 'set to auto-increment cursor LCDCMD Lcd_pin,1 'clears display' - --[noparse][[/noparse] Main Routine ]---------------------------------------------------- start: FOR temp = 0 TO 22 READ temp, char IF temp = 19 THEN Next_line out: LCDOUT 0,non_op,[noparse][[/noparse]char] PAUSE 100 ' This number ajest the rate of displaying the text NEXT again: GOSUB keyScan IF press = 0 THEN again DEBUG "key pressed = ", HEX key,CR LCDCMD Lcd_pin,1 'This is the line I inserted LCDOUT 0,0,[noparse][[/noparse]"Keypress"] 'This is the line I inserted PAUSE 100 press = 0 GOTO again
Subroutine keyScan basically scans for the keypress on the 4 x 4 matrix keypad and output the value on to the debug window. Any help appreciated.
Thanks in advance,
Gab
Comments
·· What values is your keypress supposed to return when you press keys?· Are you sure that routine is working, since you didn't include it?· Also, your "again:" label is in a bad spot, but I didn't know if that was just from the copy and paste, or what.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
·· The commands he's using correspond to a Parallel LCD Display.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Heres my keyScan subroutine:
Currently, my program would display out the values of the keypress in the Debug window. E.g. when I pressed the number 7 button on the keypad, the Debug window will output "Keypress is: 7".
With that done, I want to try outputting the word "Keypress" onto the·LCD im using,(which is 2 x 20 by the way)·when ANY keypress on the keypad is detected. Preferably I would like the LCD to output the values of the keypress along with the Debug window,· but I would like to get the "Keypress" output·right first before I go ahead with it.
Regards,
Gab
·· Have you verified that the LCD output works by itself?· I would write a small separate program which outputs text to the LCD to verify it is working.· Now that I see what you're trying to do, it seems like it should work.· Unless your LCD isn't working.· Let me ask you this.· Do you see the correct output on the DEBUG screen?· Try putting a DEBUG statement after the LCD commands to see if the program is getting past them.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
·· No mistake...I think you guys have Parallel Displays too...But the LCD commands only work on Parallel Displays, that's how I knew.· Don't know the brand, but that part shouldn't matter.· I'm just unclear if the display is properly initializing at all...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Sorry for the slow reply. Computer was kinda dodgy these few days but got it sorted out now. Anyway, I played with the device again and realised I forgotten to put in a MAINIO command before sending out a command to the LCD (which was actually
connected to the MAIN I/O pins). The keys are on AUXIO, thus need the switching command. Anyway, thanks for your time.
Regards,
Gabe