|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Pneumatics, getting XBox input
Hey, I am from Team 5676 and we have some problems with the programming. I looked in some pneumatic threads, but I didn't found anything similar.
We want to work with pneumatics who get controlled by the Xbox controller. When the XBox controller and all the buttons are defined, what is the best way to get the Xbox Input to let the pneumatics start working? Code:
if(XboxController.button[0] == true)
{
pistonArm.set(DoubleSolenoid.Value.kForward);
System.out.println("'A' button is pressed: Piston moves forward");}
with best wishes The Hornets |
|
#2
|
||||
|
||||
|
Re: Pneumatics, getting XBox input
Quote:
Code:
if(XboxController.getRawButton(0))
{
pistonArm.set(DoubleSolenoid.Value.kForward);
System.out.println("'A' button is pressed: Piston moves forward");}
For example: Code:
// if 5 is bigger than 4 will evaluate to true
if(5 > 4) {
System.out.println("5 is bigger than 4!");
}
// less efficient way of doing the same thing posted above
if((5 > 4) == true) {
System.out.println("5 is bigger than 4!");
}
Code:
public void toggleSolenoid1() {
if(solenoid1.get() == DoubleSolenoid.Value.kForward) {
solenoid1.set(DoubleSolenoid.Value.kReverse);
} else {
solenoid1.set(DoubleSolenoid.Value.kForward);
}
}
|
|
#3
|
|||||
|
|||||
|
Re: Pneumatics, getting XBox input
The issue is that you need to change
Code:
if(XboxController.button[0] == true) Code:
if(XboxController.button[0].get() == true) |
|
#4
|
|||
|
|||
|
Re: Pneumatics, getting XBox input
This is something my team is using
Code:
if (DriverButtons.X.changedDown)
{
if (HighGear)
{
Shifter.set(Value.kReverse);
} else {
Shifter.set(Value.kForward);
}
HighGear=!HighGear;
}
but if do not want a toggle then you can easily do Code:
if (DriverButtons.X.current)
{
pistonArm.set(Value.kReverse);
}
else {
pistonArm.set(Value.kForward);
}
|
|
#5
|
|||
|
|||
|
Re: Pneumatics, getting XBox input
Quote:
A few common ones include Code:
if (leftStick.getRawButton(5)) {} // if the button is held(or true) it would run the code
if (!leftStick.getRawButton(5)) {} // the ! operator inverts your boolean, so when the 5 button is not held it would run this code using the == true is a bit redundant when java interprets true as the default for running your if anyway and using ! would invert it to false.
if (leftStick.getRawButton(5) && rightStick.getRawButton(5)) {} // this would only run the if when left and(&&) right stick are both held
|
|
#6
|
|||
|
|||
|
Re: Pneumatics, getting XBox input
Thank you all so much!!! So we changed all this staff but I just donīt get it to read the buttons. It tells me that XboxController.button would not be visible. But itīs all declared as public and the XboxController and the buttons are all imported. Any suggestions or ideas???
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|