Pneumatics with command based programming

Hello everyone I am from team 6429 this is our forst year in FRC and I am the programmer I am doing command based programming it was going well until the pneumatics showed their faces to me I do not know how to control pneumatics (single solenoid) on command based programming. I have short time to finish program so I need a quick help pls. Also I am using java.

Do you have some of the code to post or any snipbit of it to show.

WPI Screensteps is very helpful for things like this, including their page on solenoids here.

This is my subsystem’s “wrist” code:
package org.usfirst.frc123.pnmatik.subsystems;

import org.usfirst.frc123.pnmatik.RobotMap;
import org.usfirst.frc123.pnmatik.commands.*;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.Solenoid;

import edu.wpi.first.wpilibj.command.Subsystem;

/**
*
*/
public class Wrist extends Subsystem {

// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTANTS

// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTANTS

// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATİONS
private final Compressor compressor1 = RobotMap.wristCompressor1;
private final Solenoid solenoid1 = RobotMap.wristSolenoid1;

// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATİONS


// Put methods for controlling this subsystem
// here. Call these from Commands.

public Compressor getCompressor1() {
	return compressor1;
}

public Solenoid getSolenoid1() {
	return solenoid1;
}

public void initDefaultCommand() {
    // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DEFAULT_COMMAND


    // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DEFAULT_COMMAND

    // Set the default command for a subsystem here.
    // setDefaultCommand(new MySpecialCommand());
}

}

And this is the command’s “Raise Wrist” code:

// RobotBuilder Version: 2.0
//
// This file was generated by RobotBuilder. It contains sections of
// code that are automatically generated and assigned by robotbuilder.
// These sections will be updated in the future when you export to
// Java from RobotBuilder. Do not put any code or make any change in
// the blocks indicating autogenerated code or it will be lost on an
// update. Deleting the comments indicating the section will prevent
// it from being updated in the future.

package org.usfirst.frc123.pnmatik.commands;

import edu.wpi.first.wpilibj.command.Command;
import org.usfirst.frc123.pnmatik.Robot;

/**
*
*/
public class RaiseWrist extends Command {

// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=VARİABLE_DECLARATİONS

// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=VARİABLE_DECLARATİONS

// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTOR
public RaiseWrist() {

// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTOR
    // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=VARİABLE_SETTİNG

    // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=VARİABLE_SETTİNG
    // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=REQUİRES
    requires(Robot.wrist);

    // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=REQUİRES
}

// Called just before this Command runs the first time
protected void initialize() {
	
}

// Called repeatedly when this Command is scheduled to run
protected void execute() {
}

// Make this return true when this Command no longer needs to run execute()
protected boolean isFinished() {
    return false;
}

// Called once after isFinished returns true
protected void end() {
}

// Called when another command which requires one or more of the same
// subsystems is scheduled to run
protected void interrupted() {
	
}

}

So what am i going to write and where (I think I should write the code to the execute in command) and am I need to write something t o subsytems actually I have no idea about pneumatics on command based programing as I said .

Thanks for your helps.

Going off the assumption you are using a Single solenoid (rather than a double), here is what I would put in ‘execute’:

RobotMap.wristSolenoid1.set(true); // open solenoid

And in the ‘end’ function:

RobotMap.wristSolenoid1.set(false); // close solenoid

Also make sure in the ‘interrupted’ function you put:

 end(); // close solenoid if command is interrupted

If you have any more questions about command-based programming let me know and I’d be more than happy to help. :]

Thank you very very much :slight_smile: