|
i think this works
I just tossed together this program now so it may not work.. one of the veteran teams please check me... From what I understand your looking to push the joystick and have the robot go one way, then flip a switch, push the joystick in the same direction and have the robot reverse course. If this is what you meant then this code should work.. Any questions just leme know, but remember this is untested...
'===============Reversed Drive Program =====================
if backdrive = 0 then frontdrive 'backdrive is switch name
if p1_y < 127 then yback
p1_y = 127 - ((p1_y - 127) Min 0 Max 127) 'p1_y > 127. takes # above 127 and makes it same distance below
goto xtest 'if previous line used ignore next 2
yback
p1_y = 127 + ((127 - p1_y) Min 0 Max 127) 'p1_y < 127. takes # below 127 it makes variable same distance above
xtest
if p1_x < 127 then xback 'now works on x-axis
p1_x = 127 - ((p1_x - 127) Min 0 Max 127) 'same as p1_y above 127, only with x-axis
goto xydone
xback
p1_x = 127 + ((127 - p1_x) Min 0 Max 127) 'same as p1_y below 127, only with x-axis
xydone:
frontdrive
'===========end of reversable drive==continue with tank drive program===========
This assumes the tank drive program is immediately after it. You need to add a variable in the declaring variable sections, it only needs to be 1 bit and i named it backdrive.
When backdrive is not pressed the robot will drive normal. When it is pressed it will first see if p1_y is above or below 127. It will then find the difference between p1_y and 127 and add or subtract it as appropriate. It then does the same using p1_x.
__________________
One Team, One Bot, One Fleet of Ambulances!
|