Serial input and processing question
Nick
Posts: 11
Im trying to write some code with a 4X5 kaypad interface to a 4X20 LCD with keypad controller. I got the Keypad controller to send serial data to the stamp.
What·I need help with is how to setup the code to process the keypress. The controller exports the kaypad as ascii· A thru T.· I was going to use the SERIN command to store the keypress value in a variable.
From there·I was going to use IF THEN statments to execute the commands.· Is there a better way to do this?·
IF variable = "A" then execute_a
IF variable = "B" then execute_b
IF variable = "C" then execute_c
and so on....
I am also having trouble with the IF THEN ELSE command.· i copied the example from the stamp manual and it didnt recognize the command.· any ideas? anyone have any pointers on IF THEN ELSE??
Thanks again,
Nick
What·I need help with is how to setup the code to process the keypress. The controller exports the kaypad as ascii· A thru T.· I was going to use the SERIN command to store the keypress value in a variable.
From there·I was going to use IF THEN statments to execute the commands.· Is there a better way to do this?·
IF variable = "A" then execute_a
IF variable = "B" then execute_b
IF variable = "C" then execute_c
and so on....
I am also having trouble with the IF THEN ELSE command.· i copied the example from the stamp manual and it didnt recognize the command.· any ideas? anyone have any pointers on IF THEN ELSE??
Thanks again,
Nick
Comments
Branch (variable-65), [noparse][[/noparse]execute_a,execute_b,execute_c]
Seems to work if you use caps.
Try
' {$PBASIC 2.5}
at the top of your code for IF THEN ELSE.
Post Edited (Orion) : 4/28/2005 11:45:02 PM GMT
Thanks for the help.
Nick
···It subtracts the ASCII value of the character from the value so that the lookdown command see a number from 0 through the highest entry, instead of a 65 through the highest entry.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
"A" - "A" = 0
"B" - "A" = 1
etc.· Does that make sense?· Remember, everything inside the Stamp is a number; it's how we use that number that is meaningful.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
kaypad VAR Byte
SERIN 7, 396, [noparse][[/noparse]keypad]
if i try to debug keypad it says keypad = 0· then it will say keypad = 255 about 10 -15 entries later.
Isnt the SERIN command suposed to wait for data before it goes to the next command?
How can i store it in the variable.
Thanks again
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
Thanks again guys.