The movement logic is controlled by SELECT-CASE . The purpose of SELECT-CASE is
to replace several IF-THEN commands that would examine the same control variable.
So, the following code structure:
SELECT lineBits
CASE %00
DEBUG "Continue forward", CLREOL
CASE %01
DEBUG "Spin Left", CLREOL
CASE %10
DEBUG "Spin Right", CLREOL
CASE %11
DEBUG "Back up and turn around", CLREOL
ENDSELECT
replaces these statements, as well as the program labels and associated code for them:
IF (lineBits = %00) THEN Go_Fwd
IF (lineBits = %01) THEN Spin_Left
IF (lineBits = %10) THEN Spin_Right
IF (lineBits = %11) THEN About_Face
and accomplishes the same objective.
SELECT-CASE is a clean solution. As programs grow, we'll examine other instructions
(like BRANCH) to replace multiple IF-THEN comparisons and route the program to
desired control routines. Keep in mind that program 3.2 doesn't actually move the
SumoBot. It simply displays the action that should be taken given the QTI inputs.
OUR FIRST OPERATIONAL SUMO PROGRAM
With the ability to move and to see the border on the Sumo ring, we have enough to
create a working Mini-Sumo program. Add a 470 Ω resistor and LED to the breadboard
as shown in Figures 3.3 and 3.4, and then load and run program 3.3.
Chapter 3: SumoBot Sensors and Border Detection · Page 29
With simple programs like this one, using
Figure 3.3: Start LED Schematic
' display actions
Need help?
Do you have a question about the Boe-Bot and is the answer not in the manual?