PULSOUT 12, 650
PAUSE 20
NEXT
RETURN
Turn_Right:
FOR pulseCount = 0 TO 20
PULSOUT 13, 850
PULSOUT 12, 850
PAUSE 20
NEXT
RETURN
Back_Up:
FOR pulseCount = 0 TO 40
PULSOUT 13, 650
PULSOUT 12, 850
PAUSE 20
NEXT
RETURN
How EscapingCorners.bs2 Works
Since this program is a modified version of RoamingWithWhiskers.bs2, only new
features related to detecting and escaping corners are discussed here.
Three extra variables are created for detecting a corner. The nibble variable
store a value between 0 and 15. Since our target value for detecting a corner is 4, the size
of the variable is reasonable. Remember that a bit variable can store a single bit, either a
1 or a 0. The next two variables (
the right size for the job since they are used to store old values of
also bit variables.
counter
old7
old5
These variables have to be initialized (given initial values). For the sake of making the
program easier to read,
counter
Boe-Bot is stuck in a corner, it is reset to 1. The
so that it looks like one of the two whiskers was pressed some time before the program
started. This has to be done because the routine for detecting alternate corners always
compares an alternating pattern, either (
). Likewise,
and
1
old5
Chapter 5: Tactile Navigation with Whiskers · Page 185
and
old7
old5
VAR
Nib
VAR
Bit
VAR
Bit
is set to 1, and when it gets to 4 due to the fact that the
IN5 = 1
have to be different from each other.
old7
' Right turn, about 90-degrees.
' Back up.
) are both bit variables. These are also
and
IN7
and
variables have to be set
old7
old5
and
) or (
IN7 = 0
IN5 = 0
can
counter
, which are
IN5
and
IN7 =
Need help?
Do you have a question about the Boe-Bot and is the answer not in the manual?
Questions and answers