Parallax Boe-Bot Student Manual page 159

Hide thumbs Also See for Boe-Bot:
Table of Contents

Advertisement

Enter, save, and run MovementWithVariablesAndOneSubroutine.bs2.
' Robotics with the Boe-Bot - MovementWithVariablesAndOneSubroutine.bs2
' Make a navigation routine that accepts parameters.
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running!"
counter
VAR
pulseLeft
VAR
pulseRight
VAR
pulseCount
VAR
FREQOUT 4, 2000, 3000
' Forward
pulseLeft = 850: pulseRight = 650: pulseCount = 64: GOSUB Navigate
' Left turn
pulseLeft = 650: pulseRight = 650: pulseCount = 24: GOSUB Navigate
' Right turn
pulseLeft = 850: pulseRight = 850: pulseCount = 24: GOSUB Navigate
' Backward
pulseLeft = 650: pulseRight = 850: pulseCount = 64: GOSUB Navigate
END
Navigate:
FOR counter = 1 TO pulseCount
PULSOUT 13, pulseLeft
PULSOUT 12, pulseRight
PAUSE 20
NEXT
PAUSE 200
RETURN
Did your Boe-Bot perform the familiar forward-left-right-backward sequence? This
program may be difficult to read at first, because the instructions are arranged in a new
way. Instead of having each variable statement and each
line, they are grouped together on the same line and separated by colons. Here, the
Word
Word
Word
Byte
Chapter 4: Boe-Bot Navigation · Page 145
' Signal program start/reset.
command on a different
GOSUB

Advertisement

Table of Contents
loading

Table of Contents