Chapter 4: Boe-Bot Navigation
· Page 163
match your Boe-Bot and particular surface. For a triangle pattern, the Boe-Bot
must travel 1 meter/yard forward, then make a 120 degree turn. This should be
repeated three times for the three sides of the triangle. You may have to adjust
the
pulseCount
EndValue
in the
Right_Rotate120
subroutine to get a precise
120 degree turn.
' Robotics with the Boe-Bot - Chapter 4 - Triangle.bs2
' Boe-Bot navigates triangle shape with 1 yard sides.
' Go forward, then turn 120 degrees. Repeat three times.
'{$STAMP BS2}
'{$PBASIC 2.5}
DEBUG "Program running!"
counter VAR Nib ' Triangle has 3 sides
pulseCount VAR Word ' Pulse count to servos
FREQOUT 4, 2000, 3000 ' Signal program start/reset.
Main:
FOR counter = 1 TO 3 ' Repeat 3 times for triangle
GOSUB Forward
GOSUB Right_Rotate120
NEXT
END
Forward:
FOR pulseCount = 1 TO 163 ' Forward 1 yard
PULSOUT 13, 850
PULSOUT 12, 650
PAUSE 20
NEXT
RETURN
Right_Rotate120:
FOR pulseCount = 1 TO 21 ' Rotate right 120 degrees
PULSOUT 13, 850
PULSOUT 12, 850
PAUSE 20
NEXT
RETURN