Datasheet
Page 50ยท Applied Robotics with the SumoBot
binary value from the right is accessed with .BIT1; the third binary value is accessed
with
.BIT2, and so on.
Here is an
IF...THEN statement you can use to determine whether the value of temp is
odd or even in ResetButtonCounter.bs2:
IF temp.BIT0 = 0 THEN
DEBUG DEC temp, " is even.", CR
ELSE
DEBUG DEC temp, " is odd.", CR
ENDIF
โ Save ResetButtonCounter as ResetButtonCounterYourTurn.bs2
โ Insert the odd/even
IF...THEN statement just before the END command in the
program.
โ Run the program, and verify that it correctly identifies each successive value of
temp as odd or even.
ACTIVITY #2: USING AND REUSING VARIABLES
The next example program demonstrates how you can do many different tasks with three
variables. It will prompt you to enter a threshold value, after which, it will prompt you to
enter up to 20 more values. To enter your values, click the Transmit windowpane shown
in Figure 2-3. Then type each value and press the enter key. When you are done entering
values, press the 0 (zero) key, then press Enter. The program will then ask you if you
want to compare the values to the threshold you entered. If you respond by pressing the
"y" key, the program will display all the values you entered and compare them to the
threshold value you entered.