Here’s some mods,
the datas are not duplicated, i was able to make it beep once with the original program, when it beep twice or more, the temp(6) variable is always different but < or > to the threshold value.
i have corrected some issue in the code, the temp bytes table must be defined to temp( 19 ) rather than 18
temp( 19 ) means 19 bytes from temp( 0 ) to temp( 18 ), this way you’re not overwritting the next variable stored in memory after the temp bytes table when using shiftin.
anyway here’s the code corrected, but i’m not sure it’s the way to go 
this way the WalkForward code will be called only one time if the joystick is pushed up…then to call it again you’ll have to release the joystick then push it again.
“normal” behavior should be to define a WalkForward code to move one step then return to main loop, then if the joystick is still pushed up it calls again the WalkForward code and move one step more etc…
I’m not understanding how you will define the Walkforward code the way you do.
see the next post for another way…
[code];-----------Bot Board Selection----------
;PS2 Controller / BotBoard II
DAT con P12
CMD con P13
SEL con P14
CLK con P15
index var byte
temp var byte(19) ; this byte table must be defined to 19 bytes long…from temp(0) to temp(18)
mode var byte
LastButtonAnalog var word
;PS2Init
high CLK
low SEL
shiftout CMD,CLK,FASTLSBPRE,$1\8,$43\8,$0\8,$1\8,$0\8] ;CONFIG_MODE_ENTER
high SEL
pause 10
low SEL
shiftout CMD,CLK,FASTLSBPRE,$01\8,$44\8,$00\8,$01\8,$03\8,$00\8,$00\8,$00\8,$00\8] ;SET_MODE_AND_LOCK
high SEL
pause 100
low SEL
shiftout CMD,CLK,FASTLSBPRE,$01\8,$4F\8,$00\8,$FF\8,$FF\8,$03\8,$00\8,$00\8,$00\8] ;SET_DS2_NATIVE_MODE
high SEL
pause 10
low SEL
shiftout CMD,CLK,FASTLSBPRE,$01\8,$43\8,$00\8,$00\8,$5A\8,$5A\8,$5A\8,$5A\8,$5A\8] ;CONFIG_MODE_EXIT_DS2_NATIVE
high SEL
pause 10
low SEL
shiftout CMD,CLK,FASTLSBPRE,$01\8,$43\8,$00\8,$00\8,$00\8,$00\8,$00\8,$00\8,$00\8] ;CONFIG_MODE_EXIT
high SEL
pause 10
LastButtonAnalog = 0
main
;-----------PS2 Mode----------
low SEL
shiftout CMD,CLK,FASTLSBPRE,$1\8]
shiftin DAT,CLK,FASTLSBPOST,[mode\8]
high SEL
;-----------------------------
pause 1
;-----------PS2 Data----------
low SEL
shiftout CMD,CLK,FASTLSBPRE,$1\8,$42\8]
PAUSE 1
shiftin DAT,CLK,FASTLSBPOST,[temp(0)\8,temp(1)\8,temp(2)\8,temp(3)\8,temp(4)\8,temp(5)\8,temp(6)\8,temp(7)\8,temp(8)\8, |
temp(9)\8,temp(10)\8,temp(11)\8,temp(12)\8,temp(13)\8,temp(14)\8,temp(15)\8,temp(16)\8,temp(17)\8,temp(18)\8]
high SEL
PAUSE 1
;-----------Basic Micro IDE terminal----------
serout S_OUT,i57600,[13, hex2 mode\2]
for index = 1 to 18
serout S_OUT,i57600," ", dec3 temp(index)\3]
next
;-----------Process Code--------------------
; use LastButtonAnalog.bit0 to bit15 for temp(3) to temp(18)
; so use bit3 for temp(6)
if temp(6) < 114 then
if LastButtonAnalog.bit3 then
sound 9, [50\8000]
LastButtonAnalog.bit3 = 0
; goto WalkForward
endif
elseif temp(6) > 142
if LastButtonAnalog.bit3 then
sound 9, [50\5000]
LastButtonAnalog.bit3 = 0
; goto WalkBackward
endif
else
LastButtonAnalog.bit3 = 1
endif
goto main [/code]