EasyManuals Logo

Parallax Boe-Bot User Manual

Parallax Boe-Bot
360 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #200 background imageLoading...
Page #200 background image
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
IN7 different from IN5?” In PBASIC, we can use the not-equal operator <> in an IF
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
(old7 <> IN7) and
is
(old5 <> IN5)? If that’s true, then, it’s time to add one to the counter that tracks
alternate whisker contacts. It’s also time to remember the current whisker pattern by
setting
old7 equal to the current IN7 and old5 equal to the current IN5.
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
ENDIF ends the code block that is executed if counter > 4.
ENDIF
This ELSE statement is connected to the IF (old7 <> IN7) AND (old5 <> IN5) THEN
statement. The
ELSE statement covers what happens if the IF statement is not true. In
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.

Table of Contents

Other manuals for Parallax Boe-Bot

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Parallax Boe-Bot and is the answer not in the manual?

Parallax Boe-Bot Specifications

General IconGeneral
BrandParallax
ModelBoe-Bot
CategoryRobotics
LanguageEnglish