Compressor is not working

We are having a problem with the compressor :frowning:
The spike relay is orange; selenoid is communicating but the compressor never starts??
heres the code:
package edu.wpi.first.wpilibj.templates;

import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Relay;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.Jaguar;

public class RobotTemplate extends SimpleRobot {
private RobotDrive robotDrive = new RobotDrive(10,9);
private Joystick Stick = new Joystick(1);
private Jaguar Shooter = new Jaguar(5);
private Jaguar Loader = new Jaguar(6);
private Compressor compressor = new Compressor(2,2);
private Solenoid pistonUp = new Solenoid(1);
private Solenoid pistonDown = new Solenoid(2);
//Relay spikeRelay;
//private Relay spikeRelay = new Relay(2);

 // public void robotInit() {
      
 //spikeRelay = new Relay(2);}

public RobotTemplate() {
    getWatchdog().setExpiration(0.5);

//spikeRelay.set(Relay.Value.kOn);
compressor.start();
//compressor.setRelayValue(Relay.Value.kForward);
}

public void operatorControl() {
    getWatchdog().setEnabled(true);
    while (isEnabled() && isOperatorControl()) {
        
        getWatchdog().feed();
      //  robotDrive.setSafetyEnabled(false);
        robotDrive.arcadeDrive(-Stick.getX(), Stick.getY());
        robotDrive.setInvertedMotor(RobotDrive.MotorType.kRearLeft, true);
        
        
        //spikeRelay.set(Relay.Value.kForward);
        
        
        
        if (Stick.getTrigger()) {
            pistonUp.set(true);
        } else if (Stick.getRawButton(3)) {
            pistonDown.set(true);
        } else {
            pistonUp.set(false);
            pistonDown.set(false);
        }
        }
    
        if (Stick.getRawButton(2)){
           Shooter.set(.75);
        } else {
           Shooter.set(0);
        }
        if (Stick.getRawButton(5)){
            Loader.set(.75);
        } else {
            Loader.set(0);
        }
        }

}

whenever you say

= new ##(parameters) (such as new Jaguar(1))

keep it all in your robot init function, because it has to run after the cRIO is done compiling.

also,

public RobotTemplate() will never run. it has to be public void robotInit()

Didn’t solve the problem, here is the simpler version of the code that we are starting all over from the begining (without messing with relay in the program):

package edu.wpi.first.wpilibj.templates;

import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.Joystick;

public class RobotTemplate extends SimpleRobot {
private Joystick Stick = new Joystick(1);
private Compressor compressor = new Compressor(2,2);
private Solenoid pistonUP = new Solenoid(1);
private Solenoid pistonDOWN = new Solenoid(2);

public RobotTemplate(){
getWatchdog().setExpiration(0.5);
compressor.start();
}


/**
 * This function is called once each time the robot enters operator control.
 */
public void operatorControl() {
    getWatchdog().setEnabled(true);
    while(isEnabled() && isOperatorControl()){
    getWatchdog().feed();
    if(Stick.getTrigger()){
    pistonUP.set(true);
    }else if(Stick.getRawButton(3)){
    pistonDOWN.set(true);
    }else{
    pistonUP.set(false);
    pistonDOWN.set(false);
    }
        
    
    }
    
    
    
}

/**
 * This function is called once each time the robot enters test mode.
 */
public void test() {

}

}

:frowning:

Everything works nice and finenow. There was some complication withhardware.
Thanks :slight_smile: