Page 186 · Robotics with the Boe-Bot
counter = 1
old7 = 0
old5 = 1
Now we get to the Detect Consecutive Alternate Corners section. The first thing we want
to check for is if one or the other whisker is pressed. A simple way to do this is to ask "is
different from
IN7
IN5
statement:
IF (IN7 <> IN5) THEN
If it is indeed one whisker that is pressed, the next thing to check for is whether or not it's
the exact opposite pattern as the previous time. In other words, is
is
? If that's true, then, it's time to add one to the counter that tracks
(old5 <> IN5)
alternate whisker contacts. It's also time to remember the current whisker pattern by
setting
equal to the current
old7
IF (old7 <> IN7) AND (old5 <> IN5) THEN
counter = counter + 1
old7 = IN7
old5 = IN5
If it turns out that this is the fourth consecutive whisker contact, then it's time to reset the
counter to 1 and execute a U-turn.
IF (counter > 4) THEN
counter = 1
GOSUB Back_Up
GOSUB Turn_Left
GOSUB Turn_Left
This
ends the code block that is executed if
ENDIF
ENDIF
This
statement is connected to the
ELSE
statement. The
statement covers what happens if the
ELSE
other words, it must not be an alternate whisker that was pressed, so reset the counter
because the Boe-Bot is not stuck in a corner.
?" In PBASIC, we can use the not-equal operator
and
equal to the current
IN7
old5
IF (old7 <> IN7) AND (old5 <> IN5) THEN
(old7 <> IN7)
.
IN5
> 4.
counter
statement is not true. In
IF
in an
<>
IF
and
Need help?
Do you have a question about the Boe-Bot and is the answer not in the manual?