Getting an error on ".set(DoubleSolenoid.Value.kReverse);"

I am just learning Pneumatics and while following along WPI's tutorial I kept coming accross an error on "ClawSelonoid.set(DoubleSolenoid.Value.kReverse);" I get the error "The method set(boolean) in the type Solenoid is not applicable for the arguments " not sure what this means or on how to fix it and other sites have not been to helpful 

This is my Robot.java file with a few empty fields removed
package frc.robot;

import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.command.Command;
import edu.wpi.first.wpilibj.command.Scheduler;
import edu.wpi.first.wpilibj.command.Subsystem;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import frc.robot.subsystems.Claw;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.DoubleSolenoid;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.Joystick;



public class Robot extends TimedRobot {
  public static OI m_oi;
public static Subsystem claw;
  Joystick stick;
  Compressor c;
  Solenoid ClawSolenoid = new Solenoid(1);
  Joystick leftJoy = new Joystick(0);
  Command m_autonomousCommand;
  SendableChooser<Command> m_chooser = new SendableChooser<>();

 
  @Override
  public void robotInit() {
    stick = new Joystick(1);
    Robot.claw = new Claw();
    
  
  }


  @Override
  public void robotPeriodic() {
  }
  
  public void Open(){
    ClawSolenoid.set(DoubleSolenoid.Value.kForward);//This is where the error is 
    
  }

  public void Close(){
   ClawSolenoid.set(DoubleSolenoid.Value.kReverse);//This is where the error is 
  }



  @Override
  public void disabledPeriodic() {
    Scheduler.getInstance().run();
  }

 

  @Override
  public void teleopPeriodic() {
   
    if (stick.getRawButton(1)) {
      ClawSolenoid.set(true);
        
    }
    else if(stick.getRawButton(2)){
      ClawSolenoid.set(false);
        
    }else{
      ClawSolenoid.set(false);
    }
    
  }
    
  


}

should be changed to

DoubleSolenoid ClawSolenoid = new DoubleSolenoid(channel1, channel2);

Unless you’re using a singal solenoid, which only plugs into one PCM port, you would just use;
ClawSolenoid.set(true);
or
ClawSolenoid.set(false);

1 Like

You declare the ClawSolenoid variable as a Solenoid, but you try to pass an enum of DoubleSolenoid type in the set method.

If you take a look at the Solenoid Javadoc you’ll see that the type of argument the set() method receives is a boolean of whether the solenoid is on/off.

The constructor you’re using to make the Solenoid is for a (single) Solenoid, but you are setting it like a DoubleSolenoid. You can either use two numbers as arguments for the two ports when you make the DoubleSolenoid, or just set to true or false for a (single) Solenoid. You’ll have to figure out which you’re physically using to decide.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.