View Single Post
  #5   Spotlight this post!  
Unread 18-02-2013, 01:13
VCEmblem VCEmblem is offline
Registered User
FRC #3880
 
Join Date: Feb 2013
Location: Kailua-Kona
Posts: 2
VCEmblem is an unknown quantity at this point
Smile Re: How to code limit switch to stop movement

You should post your code; this is what my team is using at the moment:

Code:
if(driveStick.GetRawButton(5) && topLimit.Get() == 1) //The arm will only move up if the limit switch is NOT pressed
{
         leftArm.Set(-1.0); //Moves the arm up
         rightArm.Set(-1.0);
}
else if(driveStick.GetRawButton(7) && bottomLimit.Get() == 1) //ditto ^
{
         leftArm.Set(0.5); //Moves the arm down
         rightArm.Set(0.5);
}
else
{
         leftArm.Set(0.0); //Stops moving the arm
         rightArm.Set(0.0);
}
The way we wired our limit switch makes it so then when the limit switch is pressed, it is equal to "0" and when it is not pressed, it is equal to "1"
Reply With Quote