Quote:
Originally Posted by SirGibbs
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");}
That is what we have, but it isn't working. It doesn't get the input. We would highly appreciate any input, ideas or solutions to make this better and solve it.
with best wishes
The Hornets
|
Your button getter method is kind of odd;
Code:
if(XboxController.getRawButton(0))
{
pistonArm.set(DoubleSolenoid.Value.kForward);
System.out.println("'A' button is pressed: Piston moves forward");}
Also, the == true part isn't essential -- if your expression will return true you don't have to add that.
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!");
}
Your pneumatic control looks good, but here's a toggle function I have been using (that I know works):
Code:
public void toggleSolenoid1() {
if(solenoid1.get() == DoubleSolenoid.Value.kForward) {
solenoid1.set(DoubleSolenoid.Value.kReverse);
} else {
solenoid1.set(DoubleSolenoid.Value.kForward);
}
}