|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#5
|
|||
|
|||
|
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. |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how do i control a piston with a joystick | Ryan Foley | Programming | 2 | 27-05-2003 17:13 |
| Fried program slots? | Jeff Waegelin | Programming | 18 | 19-03-2003 18:08 |
| question about one joystick drive programing | james700 | Programming | 13 | 29-01-2003 14:49 |
| robot goes haywire with the one joystick default code | Miles | Programming | 7 | 24-01-2003 14:58 |
| joystick problem | archiver | 2000 | 12 | 23-06-2002 23:08 |