View Single Post
  #2   Spotlight this post!  
Unread 10-02-2003, 17:46
Skabana159's Avatar
Skabana159 Skabana159 is offline
Robotics and Field Hockey
AKA: Jesse C. Owens
#0159 (Alpine Robotics)
Team Role: Mentor
 
Join Date: Mar 2002
Rookie Year: 2000
Location: Ft. Collins, CO
Posts: 92
Skabana159 is on a distinguished road
Send a message via AIM to Skabana159
What you should do in instances like this is write psuedo-code in english. You should try this:

If the middle sensor is on, then I want to go straight.
If only the left sensor is on, then I want to turn left.
If only the right sensor is on, then I want to turn right.
If no sensors are on, then spin in a circle.

Now, go on to write your code:

If (rc_sw2) then gostraight
If (rc_sw1)&(rc_sw3 = 0) then turnleft
If (rc_sw3)&(rc_sw1 = 0) then turnright
goto turnleft

gostraight:
p1_x = 127
p1_y = 200 'random forward speed, should be tested on bot
goto restofcode

turnleft:
p1_x = 84
p1_y = 127
goto restofcode

turnright:
p1_x = 200
p1_y = 127

restofcode:
...
...
...
serout ...
__________________
"What most people do not understand is that the Buddha, the Godhead, resides just as comfortably in gears and circuits as in hills and trees. To believe otherwise is to dilute the Godhead."
-Robert Pirsig, Zen and the Art of Motorcycle Maintenance