Chapter 2: Your Boe-Bot’s Servo Motors
· Page 75
FOR myCounter = 1 TO 10
DEBUG ? myCounter
PAUSE 500
NEXT
DEBUG CR, "All done!"
END
Your Turn – Different Start and End Values and Counting in Steps
You can use different values for the
StartValue
and
EndValue
arguments.
√
Modify the
FOR…NEXT
loop so it looks like this:
FOR myCounter = 21 TO 9
DEBUG ? myCounter
PAUSE 500
NEXT
√
Run the modified program. Did you notice that the BASIC Stamp counted down
instead of up? It will do this whenever the
StartValue
argument is larger than
the
EndValue
argument.
Remember the optional
{STEP
StepValue
}
argument? You can use it to make
myCounter
count in steps. Instead of 9, 10, 11…, you can make it count by twos (9, 11,
13…) or by fives (10, 15, 20…), or whatever
StepValue
you give it, forwards or
backwards. Here’s an example that uses it to count down in steps of 3:
√
Add
STEP 3
to the
FOR…NEXT
loop so it looks like this:
FOR myCounter = 21 TO 9 STEP 3
DEBUG ? myCounter
PAUSE 500
NEXT
√
Run the modified program and verify that it counts backwards in steps of 3.
ACTIVITY #6: TESTING THE SERVOS
There’s one last thing to do before assembling your Boe-Bot, and that’s testing the
servos. In this activity, you will run programs that make the servos turn at different
speeds and directions. By doing this, you will verify that your servos are working
properly before you assemble your Boe-Bot.