Page 226 ·
Robotics with the Boe-Bot
difference = difference / Denominator
RETURN
There is a better way though.
√
Leave the
Average_And_Difference
routine like this:
Average_And_Difference:
average = tim timeLeft / 2
difference = average / Denominator
RETURN
√
Next, make this change in the variable declarations:
Figure 6-13:
Modify RoamingTowardTheLight.bs2 to Save a Word of RAM
' Unchanged code
average VAR Word
difference VAR Word
' Changed to save Word of RAM
average VAR Word
difference VAR average
We don’t really need the
average
variable, but the program will make more sense to
someone trying to understand it if we use the word
average
in the first line and the word
difference
in the second line. Here is how to create an alias name
difference
for the
average
variable.
difference VAR average
Now, both
average
and
difference
refer to the same word of RAM.
√
Test your modified program and make sure it still works properly.