joystick var word 'declaration for joystick RCTIME variable and position of the SmartMotor variable position var word serout 1,16468,["O=0",13] 'send out serial command through pin 1 at 9600 baud to motor to set origin at its current position '13 is the ASCII character for return check: 'CHECK function to determine where the joystick and the motor are high 5 'initialize pin 5 to HIGH (off) for RCTIME purposes low 2 'initialize pin 2 to LOW (5V) for RCTIME purposes pause 10 'wait 10 milliseconds for capacitor to get charged for RCTIME purposes rctime 5,1,joystick 'serout 4,16468,["RP",13] 'send out serial command through pin 4 at 9600 baud to motor to RP (Report Position) 'serin 5,16468,[position] 'receive serially through pin 5 the position of the motor debug dec ? joystick 'display the joystick RCTIME resistance position onto the screen if joystick=1 then clockwise 'IF statements to turn either counter-clockwise/clockwise depending where the joystick is if joystick>1000 then counterclockwise goto nothing 'goto NOTHING function if the joystick is centered goto check 'repeat CHECK function forever nothing: 'NOTHING function to shut down motor if joystick centered serout 1,16468,["OFF",13] goto check 'go back to CHECK where the joystick is clockwise: 'CLOCKWISE function to move motor clockwise at 900,0000 counts/sample at 400 acceleration serout 1,16468,["MV",13,"V=900000",13,"A=400",13,"G",13] goto check 'go back to CHECK where the joystick is counterclockwise: 'COUNTERCLOCKWISE function to move motor counterclockwise at 900,0000 counts/sample at 400 acceleration serout 1,16468,["MV",13,"V=-900000",13,"A=400",13,"G",13] goto check 'go back to CHECK where the joystick is