View Single Post
  #9   Spotlight this post!  
Unread 17-02-2016, 20:13
Lesafian Lesafian is offline
Registered User
AKA: Jeremy Styma
FRC #6077 (Wiking Kujon)
Team Role: Programmer
 
Join Date: Feb 2016
Rookie Year: 2016
Location: Posen, Michigan
Posts: 22
Lesafian is an unknown quantity at this point
Re: Issues with LimitSwitch

Quote:
Originally Posted by rich2202 View Post
At the beginning of OperatorControl, you check the limit switch, and stop slidemotor if it the switch is true.

So, make sure the limit switch returns 1 (true) when it is reached, and 0 (false) when it is not.

However, you code continues to execute, and at:


you set the speed of the motor, without regard to the limit switch.
So would something like this fix it?

Code:
			if (limit1.get() == true) {
				
				slideMotor.stopMotor();
				
			} else if (limit1.get() == false) {
				
				if (Math.abs(xboxController.getRawAxis(5)) > .1) {
					
					slideMotor.set(xboxController.getRawAxis(5));
					
				} else {
					
					slideMotor.stopMotor();
					
				}
			}
Reply With Quote