Hi guys, our team is trying to use a limit switch to stop the lifting mech powered by 2 victor motor controllers from bottoming out or flying off the top. But I can’t get the switch to work properly.
public class Robot extends SampleRobot {
RobotDrive robot;
Joystick stick;
Joystick xbox;
Victor victor1;
Victor victor2;
DigitalInput limit;
boolean limitPressed = false;
boolean buttonPressedForwardVictor = false;
public Robot() {
robot = new RobotDrive(0, 1);
stick = new Joystick(1);
xbox = new Joystick(0);
limit = new DigitalInput(4);
victor1 = new Victor(4);
victor2 = new Victor(5);
}
public void operatorControl() {
while (isOperatorControl() && isEnabled()) {
stick.getThrottle();
robot.arcadeDrive(stick.getY(), stick.getX());
Timer.delay(0.1);
if(limit.get()) {
limitPressed = true;
}
if(limitPressed = true) {
victor1.set(0);
victor2.set(0);
}
if (xbox.getRawButton(4)) {
victor1.set(1);
victor2.set(1);
buttonPressedForwardVictor = true;
} else if (buttonPressedForwardVictor = true) {
victor1.set(0);
victor2.set(0);
buttonPressedForwardVictor = false;
}
if (xbox.getRawButton(1)) {
victor1.set(-1);
victor2.set(-1);
}
}
}