View Single Post
  #1   Spotlight this post!  
Unread 23-02-2016, 00:05
Noviv's Avatar
Noviv Noviv is offline
Registered User
FRC #1477 (Texas Torque)
Team Role: Programmer
 
Join Date: Jun 2015
Rookie Year: 2013
Location: Texas
Posts: 5
Noviv is an unknown quantity at this point
Re: Help programming pneumatics

You will just need to set the value of the pneumatic to one position while the button is being pressed, and the other when it is not.

Psuedocode:
Code:
if (A button is pressed) {
    pneumatic.set(on);
} else {
    pneumatic.set(off);
}
Java Single Solenoid:
Code:
Solenoid solenoid = new Solenoid(port);
if (operator.getRawButton(1)) {//example
    solenoid.set(true);
} else {
    solenoid.set(false);
}
Java Single Solenoid:
Code:
DoubleSolenoid solenoid = new DoubleSolenoid(portA, portB);
if (operator.getRawButton(1)) {
    solenoid.set(DoubleSolenoid.Value.kForward);
} else {
    solenoid.set(DoubleSolenoid.Value.kReverse);
}
getRawButton(1) should be mapped to the A button on Xbox controllers. Switch it to getRawButton(2) for Logitech controllers.