10
Parallax, Inc.
•
Boe-Bot Tank Tread Kit (#28106)
03/2004
Go_Left: ' turn to left
FOR pulses = 1 TO 15
PULSOUT LMotor, LStop
PULSOUT RMotor, RFwd
PAUSE 20
NEXT
RETURN
Go_Right: ' turn to right
FOR pulses = 1 TO 15
PULSOUT LMotor, LFwd
PULSOUT RMotor, RStop
PAUSE 20
NEXT
RETURN
U_Turn: ' turn around
IF (yAxis > YThresh) THEN
GOSUB Back_Up ' back-up if flat terrain
ENDIF
PULSIN TiltX, IsHigh, xAxis ' check longitudinal tilt
xAxis = xAxis / 100 ' filter reading
IF (xAxis < 24) THEN ' turn left
FOR pulses = 1 TO 60
PULSOUT LMotor, LRev
PULSOUT RMotor, RFwd
PAUSE 20
NEXT
ELSE ' turn right
FOR pulses = 1 TO 60
PULSOUT LMotor, LFwd
PULSOUT RMotor, RRev
PAUSE 20
NEXT
ENDIF
RETURN
Back_Up: ' back up a bit
FOR pulses = 1 TO 10
PULSOUT LMotor, LRev
PULSOUT RMotor, RRev
PAUSE 20
NEXT
RETURN