Quote:
Originally Posted by Kingofl337
This is not correct, call the Compressor class tell it the digital input and the spike port and it will take care for you.
ex: Compressor myComp = new Compressor(1,1); //That's all you need
|
By default, the compressor is not enabled until you call the start() method on it. This is needed in addition to the creation of a Compressor object.
Quote:
Originally Posted by bamse
Howdy...
We had to insert this piece of code in the operatorControl() as well,
// New compressor code...
if (airCompressor.getPressureSwitchValue()) {
airCompressor.setRelayValue(edu.wpi.first.wpilibj. Relay.Value.kOff);
} else {
airCompressor.setRelayValue(edu.wpi.first.wpilibj. Relay.Value.kOn);
}
And don't forget to turn the compressor off when exiting your operatorControl loop...
airCompressor.setRelayValue(edu.wpi.first.wpilibj. Relay.Value.kOff);
|
Make sure to call start() on the compressor object, and also make sure that it is a class member so it does not go out of scope. Since the example code in post #5 shows no declaration for airCompressor, my best guess is that you're creating a new one each loop.
The example should look more like this:
Code:
....
public class Airsystem extends SimpleRobot {
private Joystick DriverStick;
private AxisCamera camera; //defines Axis Camera
private Solenoid s1,s2; //defines solenoids
private Compressor airCompressor;
public Airsystem() {
DriverStick = new Joystick(1); // USB port
airCompressor = new Compressor(1,1); //Digtial I/O,Relay
airCompressor.start(); // Start the air compressor
s1 = new Solenoid(1); // Solenoid port
s2 = new Solenoid(2);
}
...