In SX Microcontrollers, SX/B Compiler and SX-Key Tool, TechnoRobbo wrote: ps2 wireless with a bs2: ' {$STAMP BS2} ' {$PBASIC 2.5} psxThumbL VAR Byte ' left thumb buttons psxThumbR VAR Byte ' right thumb buttons psxJoyRX VAR Byte ' r joystick - X axis psxJoyRY VAR Byte ' r joystick - Y axis psxJoyLX VAR Byte ' l joystick - X axis psxJoyLY VAR Byte ' l joystick - Y axis idx VAR Nib tmpout VAR Byte PsxAtt PIN 9 ' PSX joystick interface PsxClk PIN 8 PsxCmd PIN 10 PsxDat PIN 11 MAIN: DO GOSUB Get_PSX_Buttons DEBUG HOME, BIN8 psxThumbL," ",BIN8 psxThumbR," ",CR'HEX2 psxID," ",HEX2 psxSta,CR DEBUG "psxJoyRX = ",DEC3 psxJoyRX ,CR DEBUG "psxJoyRY = ",DEC3 psxJoyRY ,CR DEBUG "psxJoyLX = ",DEC3 psxJoyLX ,CR DEBUG "psxJoyLY = ",DEC3 psxJoyLY ,CR LOOP ' -----[ Subroutines ]----------------------------------------------------- Get_PSX_Buttons:' This routine REQUIRES inverted clock signal from DIR10=1 DIR11=0 LOW PsxClk LOW PsxAtt 'GOTO test 'request data tmpout=$01 FOR idx=0 TO 7 PsxCmd=tmpout.LOWBIT(idx) PULSOUT PsxClk,2 NEXT PAUSE 1 tmpout=$42 FOR idx=0 TO 7 PsxCmd=tmpout.LOWBIT(idx) PULSOUT PsxClk,2 NEXT PAUSE 1 tmpout=$00 FOR idx=0 TO 7 PsxCmd=tmpout.LOWBIT(idx) PULSOUT PsxClk,2 NEXT PAUSE 1 FOR idx=0 TO 7 psxThumbL.LOWBIT(idx)=PsxDat PULSOUT PsxClk,1 NEXT FOR idx=0 TO 7 psxThumbR.LOWBIT(idx)=PsxDat PULSOUT PsxClk,1 NEXT FOR idx=0 TO 7 psxJoyRX.LOWBIT(idx)=PsxDat PULSOUT PsxClk,1 NEXT FOR idx=0 TO 7 psxJoyRY.LOWBIT(idx)=PsxDat PULSOUT PsxClk,1 NEXT FOR idx=0 TO 7 psxJoyLX.LOWBIT(idx)=PsxDat PULSOUT PsxClk,1 NEXT FOR idx=0 TO 7 psxJoyLY.LOWBIT(idx)=PsxDat PULSOUT PsxClk,1 NEXT HIGH PsxAtt RETURN END ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=90317#m138502 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)