'--These subroutines must be after the main program----
'-------------------------------------------------
swonoff:
do while input1=0 'wait till switch pressed
loop
do while input1=1 'wait till switch released
loop
return 'return to main program
'-------------------------------------------------
fwd:
let pins=%01010000 'both motors forwards
pause 100 'let them run
'------
let pins=0 'stop motors
return 'return to main program
'-------------------------------------------------
fwdsteer:
let pins=%01010000 'both motors forwards
pause 100 'let them run
' * * * adjust these next three lines * * *
'------
let pins=%xxxx0000 'spin left/right
pause x 'amount of spin
' pause 0 ' uncomment this for half units.
'------
let pins=0 'stop motors
return 'return to main program
'-------------------------------------------------
rev:
let pins=%10100000 'both motors rev
pause 100 'let them run
'------
let pins=0 'stop motors
return 'return to main program
'-------------------------------------------------
revsteer:
let pins=%10100000 'both motors rev
pause 100 'let them run
' * * * adjust these next three lines * * *
'------
let pins=%xxxx0000 'spin left/right
pause x 'amount of spin
' pause 0 ' uncomment this for half units.
'------
let pins=0 'stop motors
return 'return to main program
'-------------------------------------------------
flash:
high 1,2 'Right & left LEDs on
pause 500
low 1,2 'Right & left LEDs off
pause 500
return 'return to main program
'-------------------------------------------------
spin180L:
let pins=%01100000 'left rev, right forward
pause 2000 'let them run
let pins=%00000000 'stop motors
return 'return to main program
'-------------------------------------------------
fwdb0:
do while b0>0 'loop as long as B0 isn't 0
gosub fwd 'move forward one unit
dec b0 'count down
loop
return 'return to main program
'-------------------------------------------------
measure: let b0=0 'start count at zero
'loop as long as *BOTH* switches are not touching a wall
do while input1=0 and input0=0
gosub fwd 'move forward one unit
inc b0 'count up
loop
return 'return to main program
'-------------------------------------------------
reach:
' loop as long as b0 isn't 0 and neither switch is pressed
do while b0>0 and input1=0 and input0=0
gosub fwd 'move forward one unit
dec b0 'count down
loop
return 'return to main program
'--------------------------------------------------