|
Re: Programming Pneumatics
Would this be correct? (Please don't steal)
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.templates;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.Timer;
/**
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the SimpleRobot
* documentation. If you change the name of this class or the package after
* creating this project, you must also update the manifest file in the resource
* directory.
*/
public class TheReaper extends SimpleRobot {
RobotDrive drive = new RobotDrive(1, 2);
Joystick leftStick = new Joystick(1);
Joystick rightStick = new Joystick(2);
Joystick miscStick = new Joystick(3);
Compressor mainCompressor = new Compressor(1,2);
Solenoid piston1extract = new Solenoid(1);
Solenoid piston1retract = new Solenoid(2);
Solenoid piston2extract = new Solenoid(3);
Solenoid piston2retract = new Solenoid(4);
public void robotinit() {
mainCompressor.start();
}
/**
* This function is called once each time the robot enters autonomous mode.
*/
public void autonomous() {
}
/**
* This function is called once each time the robot enters operator control.
*/
public void operatorControl() {
while (isOperatorControl() && isEnabled()){
drive.tankDrive(-leftStick.getY(), -rightStick.getY());
Timer.delay(0.01);
if(miscStick.getRawButton(3)){
piston1extract.set(true);
piston1retract.set(false);
}else if(miscStick.getRawButton(4)){
piston1extract.set(false);
piston1retract.set(true);
}if(miscStick.getRawButton(7)){
piston2extract.set(true);
piston2retract.set(false);
}else if(miscStick.getRawButton(8)){
piston2extract.set(false);
piston2retract.set(true);
}else{
piston1extract.set(false);
piston1retract.set(false);
piston2extract.set(false);
piston2retract.set(false);
}
}
}
/**
* This function is called once each time the robot enters test mode.
*/
public void test() {
}
}
__________________
Wait, what?
|