Al..
There is some odd behaviour now ... :-(
Here's updated code with added display options and cosmetics for testing.
So far # must be pressed twice and 126 is displayed for any number (1,2 or 3 digits) ??
Check clearing of var's and counter , will continue with tests, I'm willing to bet it's something really small causing the problem
Kind regards
Dennis
Code:'keypad capture code begins here 'variables begin here Array var Byte [3] 'byte array holds keypresses A0 var byte 'counter/index B0 var Byte 'working sum of bytes KeyPress Var Byte ' will contain the ascii character of the key pressed passed from myvar myvar var byte 'holds keypress byte digit var byte 'check the number of bytes entered start: A0=0 'set index to 0 Ini: 'main loop lcdout $fe,1 lcdout "enter number" @ READKEYPAD _myvar 'read keypress variable and place in myvar LOOKUP myvar,[0,"123A456B789C*0#D"],myvar 'use lookup table to diplay proper keypress keypress = myvar 'pass the variable to solve strange character problem ' will contain the ascii character of the key pressed lcdout keypress pause 1000 lcdout $fe,1 If KeyPress = "*" then goto retry If KeyPress = "#" then 'if # conditions begin here if A0=2 then 'if counter is 2 then sum all bytes B0= (Array[0]*100)+(Array[1]*10)+Array[2] 'byte sum lcdout "3 digits ",dec B0,$0d,$0a pause 1000 lcdout $fe,1 HSEROUT ["here is the total ",dec B0,$0d,$0a] 'send result to pc com port endif if A0=1 then B0= (Array[0]*10)+Array[1] lcdout "2 digits " ,dec B0,$0d,$0a pause 1000 lcdout $fe,1 HSEROUT ["here is the total ",dec B0,$0d,$0a] endif if A0=0 then B0= Array[0] lcdout "1 digit " ,dec B0,$0d,$0a pause 1000 lcdout $fe,1 HSEROUT ["here is the total ",dec B0,$0d,$0a] endif A0=0 Array[0]=0 Array[1]=0 Array[2]=0 ENDIF If A0>2 then Ini Array[A0]=KeyPress -48 A0=A0+1 goto Ini retry: lcdout "retry" pause 1000 lcdout $fe,1 A0=0 myvar=0 goto ini goto start end




Bookmarks