Quote:
Originally Posted by Lesafian
Won't this only work if I move the stick up? Shouldn't I need both > and < .1 if I'd like to both increase and decrease
Example of what I mean:
Code:
if (Math.abs(xboxController.getRawAxis(5)) > .1) {
//set your motor output to the axis value
slideMotor.set(xboxController.getRawAxis(5));
}else if (Math.abs(xboxController.getRawAxis(5)) < .1 {
slideMotor.set(xboxController.getRawAxis(5));
}
|
No. The math.abs function transforms your value to positive.
if (Math.abs(xboxController.getRawAxis(5) < .1) is equivalent to if(xboxController.getRawAxis(5) < .1 && xboxController.getRawAxis(5) > -.1)
Let's say you put Math.abs(-0.05). that will output 0.05. I recommend you try it out and print in the Riolog. That saves you a few lines in your code, instead of testing for both positive and negative values.