Quote:
Originally posted by Mark McLeod
(BTW: This was indented for readability when I typed it in)
|
Mark,
To preserve indentation, put your code inside {code}...{/code} vBcode tags. (Replace the curly braces with square brackets.)
Here's your code with them:
Code:
'----------Put these in your declaration section
'These are the # of program loops that completes the movement
FIRST_LEG CON 40 '~ 1 second assuming delta_t=0
SECOND_LEG CON 200 '~5.2 seconds
THIRD_LEG CON 250 '~6.5 seconds
'The last leg you define here should not be > 577 (15 sec.)
auto_counter VAR WORD
'------------Put this before your main loop
auto_counter = 0
'-----------Put this immediately after your Serin command
' We are just overriding the joystick values as if the driver were
' moving the joystick
IF auto_mode = 0 then NoAuto
auto_counter = auto_counter + 1
'Can also do: auto_counter = auto_counter + 1 + delta_t
If auto_counter >= FIRST_LEG then LEG2
'These values should be what your driver would normally do
'with the joystick to accomplish what you want to do
p1_x = 254
p1_y = 0
Goto NoAuto
LEG2:
If auto_counter >= SECOND_LEG then LEG3
p1_x = 254
p1_y = 0
Goto NoAuto
LEG3:
If auto_counter >= THIRD_LEG then NoAuto
'Make sure you come to a stop as the last LEG
p1_x = 127
p1_y = 127
Goto NoAuto
NoAuto:
'------------The rest of your regular code