Go to Post FIRST - Breaking stereotypes everywhere - Sparks333 [more]
Home
Go Back   Chief Delphi > Technical > Technical Discussion
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Spotlight this post!  
Unread 16-01-2002, 20:41
Joseph F Joseph F is offline
Registered User
#0506 (Steel Friars)
 
Join Date: Jan 2002
Location: New York
Posts: 59
Joseph F is an unknown quantity at this point
Send a message via AIM to Joseph F
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!
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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


All times are GMT -5. The time now is 05:35.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi