storing numbers greater than 9 one digit at a time
grkblood13
Posts: 31
hey, im running into a problem with my keypad. the problem is storing numbers greater than 9. say the number is 39. they way the key pad works is that it doesnt recognize 39, it recognizes· 3 and 9 because of the coding.
is there a way to store 3 in a variable, then store a 9 next to the 3 to make it 39?
is there a way to store 3 in a variable, then store a 9 next to the 3 to make it 39?
Comments
Now, if you need two "characters" from the keypad to be available as decimal values elsewhere in the program, you'll need to do a little work to convert the BCD array into something useful.
Is this helpful?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
SERIN 6,baud,[noparse][[/noparse]SDEC3 keyval] 'stay here until a valid +/- 3 digit number is read
The system will sit and wait for as many characters as determined by "SDEC3". ( here it was for +/- 3 digits.). keyval is a WORD variable.
It just sees each keypress as a different digit and puts them together for you. See SERIN in the Help file.
If you don't have a serial keypad, the previous post will work fine.
Cheers,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk
http://www.siskconsult.com
·
Or something like that. The above would stop reading in key presses after 4 strokes or "enter" -- %1011 -- whichever came first. Without knowing precisely how you are reading the keypad it's hard to guage.
Of course there are lots of ways to skin a cat -- the above is just a super-simple example.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
i dont see why this wont work but...it doesnt
for example, 12 is displayed as "10", 123 is displayed as "101"
any suggestions?
When you say LOW 12: LOW 13: LOW 14: LOW 15 -- you are setting these to Outputs, and Outputting a 'LOW'.
The IF's then try to read those pins as inputs. This implies you have something on the 'far side' of that pin, trying to drag it high. This won't work, and if you don't have current limiting resistors may damage stuff.
If you're trying to drive a 'matrixed switch array', I think you have to read 4 OTHER wires to get the states of the key-presses.
Post Edited (grkblood13) : 4/9/2007 10:32:20 PM GMT