Page 1 of 1

KEYPAD

Posted: Wed Oct 03, 2007 8:50 am
by wayne millard
Can you wright a number to a variable larger than 11 with the keypad.
I would like type numbers in like a calculator and then read number :D

Posted: Wed Oct 03, 2007 9:46 am
by Benj
Hello Wayne

Yes this can be acheived. The easiest way is probably to convert the incoming numbers from the keypad into a string.

To do this first create a string variable and two byte variables in flowcode. The variables should be named string_var, index_var and keypad_var.

Firstly initialise the index variable to 0 and set up a loop. The loop can be a specific number of cycles or can run until a certain key is pressed on the keypad.

Inside the loop you should read the keypad ascii into a variable.

If the data in the variable is valid (if a key has been pressed) then create a calculation with the following.

string_var[index_var] = keypad_var

Then increment the index variable.

Once your string is as long as you want then exit the loop and you have your string of number characters. This can the be output to the LCD using the PrintString function.