View Single Post
  #4   Spotlight this post!  
Unread 25-01-2014, 14:02
LFRobotics's Avatar
LFRobotics LFRobotics is offline
Registered User
FRC #4623
 
Join Date: Jan 2014
Location: Little Falls, MN
Posts: 95
LFRobotics is on a distinguished road
Re: How to Program Limit Switches

After looking around a bit I have learned that I must assign a port for it in RobotMap - I did that.

Then what I can do is create a command to move the motor in one direction and put something like this:

Quote:
if limit switch is active(1)
in isFinished() so that when the limit switch is pressed the command will finish

Then have a second command that moves the motor in the opposite direction - all the same stuff in the isFinished() except it would be assigned to the second limit switch. When the limit switch is pressed the motor would stop.

I could then put these two commands in a command group like this

Quote:
addSequential(new command);
addSequential(new secondCommand);
and the motor would move until it hit the limit switch - stop - and then return to its original position.

I have that all figured out but what I don't get is:

What would I put in a subsystem for the limit switches?

What would I write in the if statement to return true in isFinished when the limit switches state is 1(closed).

Quote:
if (something) {
return true;
}
else {
return false;
}
THANKS a ton for the help!