Hi,
The simple way to do this would be with an if statement:
Code:
double speed = getJoystickAxis();
if(limitswitch.get() && speed<0)
{
speed=0;
}
motor.set(speed);
That makes your motor output 0 instead of a negative value when your switch is pressed, but still allows it to have a positive value