Datasheet
Page 150· Applied Robotics with the SumoBot
√ Save the example program as LookupExampleYourTurn.bs2
√ Add these constant declarations with the
CON directive:
C_6 CON 1046
D_6 CON 1175
E_6 CON 1319
F_6 CON 1397
G_6 CON 1580
A_6 CON 1760
B_6 CON 1976
C_7 CON 2093
√ Change the lookup table to this:
LOOKUP counter, [C_6, D_6, E_6,
F_6, G_6, A_6,
B_6, C_7], note
√ Run the program, and verify that it works the same as before.
A Servo Control Subroutine with the LOOKUP Command
In addition to the counter and temp variables, this activity's example program will use
a nibble variable named
maneuver:
maneuver VAR Nib ' SumoBot travel maneuver
The maneuver variable will be set equal to various constants before calling a servo
control subroutine.
Forward CON 0 ' Forward
Backward CON 1 ' Backward
RotateLeft CON 2 ' RotateLeft
RotateRight CON 3 ' RotateRight
For example, you can set maneuver equal to a value and then call the servo control
subroutine like this:
maneuver = Forward
GOSUB Pulse_Servos
If you want to deliver 35 pulses, put it in a FOR...NEXT loop:
FOR counter = 1 TO 35 ' Forward 35 pulses
maneuver = Forward
GOSUB Pulse_Servos
NEXT