|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Re: Is my Java code ok?
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));
}
|
|
#2
|
||||
|
||||
|
Re: Is my Java code ok?
Quote:
|
|
#3
|
|||||
|
|||||
|
Re: Is my Java code ok?
Quote:
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. Last edited by MaGiC_PiKaChU : 03-02-2016 at 19:42. Reason: fixed operator |
|
#4
|
||||
|
||||
|
Re: Is my Java code ok?
That should be an && (and) in your compound statement instead of an or.
|
|
#5
|
|||||
|
|||||
|
Re: Is my Java code ok?
you're right. Fixed it
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|