View Single Post
  #7   Spotlight this post!  
Unread 03-02-2006, 13:04
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: problem with using a loop

You definitely want an if statement.
Code:
    if ( (p1_x > 122) && (p1_x < 132) && rc_dig_in01 )
      pwm11 = 50;
I'm assuming you intend to drive a motor backwards until it reaches a set position and activates a limit switch.

Note that I made it test to see that p1_x is in a range around 127, instead of exactly 127. Joysticks will almost never return to exactly center when you let go of them, and the center point will sometimes change with time.