http://www.picbasic.co.uk/forum/showthread.php?t=6050
Posts #3 and #5
http://www.picbasic.co.uk/forum/showthread.php?t=6050
Posts #3 and #5
Hi savnik,
See if I read you correctly.
You want the user to be able to press a series of buttons, on your keypad. You would like the PIC to take this series of separate button values and “string them together” (“concatenate” them). Then use them as a PIC WORD variable in your program.
You are able to read the individual button presses, but are having trouble putting them together to make the variable.
Is that close?
-Adam-
Ohm it's not just a good idea... it's the LAW !
Ok, well that makes a bit more sense to me...
getword:
for x = 0 to 3
Gosub getkey ' Get a key from the keypad
keyin(x) = key 'save the individual keypresses
lcdout I,Line2 + x,#key ' Display ASCII key number
next
outval = ( keyin(0) * 1000 ) + ( keyin(1) * 100 ) + ( keyin(2) * 10 ) + keyin(3)
return
Perhaps somthing like this will do what you want.
Code:getword: value = 0 for x = 0 to 3 Gosub getkey ' Get a key from the keypad lcdout I,Line2 + x,#key ' Display ASCII key number SELECT CASE x CASE 0 value = value + (key * 1000) CASE 1 value = value + (key * 100) CASE 2 value = value + (key * 10) CASE 3 value = value + key END SELECT next return
Maybe this is more effectiv:
Code:getword: value = 0 for x = 0 to 3 Gosub getkey ' Get a key from the keypad lcdout I,Line2 + x,#key ' Display ASCII key number value=Value*10+key next return
PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2
sorry but my english is not good
when press the button 2 on keyboard the LCD show 2 on first position and after when press the button 4 on keyboard the LCD show 4 on second position etc.
I want the number 2,4,3,8 to be a variable (dec 2.348)
Bookmarks