Datasheet

Page 148· Applied Robotics with the SumoBot
Your Turn - Using PIN Definitions and Constants
Instead of the number 13 in the PULSOUT command's Pin argument, the example program
can use the
PIN directive ServoLeft. Likewise, the program can use ServoRight in
place of the number 12. Since we know that 650 is the
PULSOUT Duration for full-
speed-clockwise, a good constant name for this number would be
FS_CW. Along the
same lines, 850 can be
FS_CCW for full speed counterclockwise, and 750 can be NO_ROT
for no rotation.
Add these
PIN directives and constant declarations to the program:
' -----[ I/O Definitions ]--------------------------------------------
ServoLeft PIN 13 ' Left servo connected to P13
ServoRight PIN 12 ' Right servo connected to P12
' -----[ Constants ]---------------------------------------------------
' Servo pulse width rotation constants
FS_CCW CON 850 ' Full speed counterclockwise
FS_CW CON 650 ' Full speed clockwise
NO_ROT CON 750 ' No rotation
Here is an example of the first one updated with PIN directives and constant names.
' SumoBot goes forward 3 seconds.
FOR counter = 1 TO 122
PULSOUT ServoLeft, FS_CCW
PULSOUT ServoRight, FS_CW
PAUSE 20
NEXT
Modify all the motion routines to use these constants.
LOOKUP Command Review
The LOOKUP command picks a value from the lookup table (the list within the square
braces) and copies that value to
Variable. The value LOOKUP picks depends on the
Index variable.
LOOKUP Index, [Value1, Value2, ... ValueN], Variable