|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
I was told this year I have to program our compressor and Solenoid for our robotic arm. I only programmed ROBOTC for FTC before. We have nobody experienced in Java and while we have a drive program I can't for the life of me find out how to program pneumatics. Can anybody help me out even if its a little?
(This is my first post, sorry if its done wrong) |
|
#2
|
||||
|
||||
|
Re: Java Pneumatics
For the Solenoids, the first thing to do is to create the Solenoid object. The constructor follows the general WPI format, with options to create it based on slot (of the Solenoid module) and channel, or just by channel.
Code:
Solenoid armSol = new Solenoid(7,4); //creates a Solenoid object in slot 7, channel 4. Code:
armSol.set(true); //turns the Solenoid on Code:
Compressor aCompressor = new Compressor(1,1); //create a compressor with the default slots and relay and pressure switch channels 1 and 1. aCompressor.start(); //start the compressor. Last edited by Patrickwhite : 15-02-2011 at 21:20. Reason: I may or may not have completely forgotten the compressor. |
|
#3
|
||||
|
||||
|
Re: Java Pneumatics
My double and single solenoid class
Code:
package com.shadowh511.mayor.outputs;
import edu.wpi.first.wpilibj.Solenoid;
/**
*
* @author sam
*/
public class MySolenoid {
private Solenoid foo;
private Solenoid bar;
private boolean doublek = false;
/*
* For a one-solenoid system
*/
public MySolenoid(int port) {
foo = new Solenoid(8, port);
doublek = false;
System.out.println("MySolenoid enabled on port " + port);
}
/*
* For a double solenoid system
*/
public MySolenoid(int port1, int port2) {
doublek = true;
foo = new Solenoid(8, port1);
bar = new Solenoid(8, port2);
System.out.println("Double MySolenoid enabled on ports " + port1 + " and " + port2);
}
/*
* For a double solenoid system, custom slot
*/
public MySolenoid(int slot, int port1, int port2) {
doublek = true;
foo = new Solenoid(slot, port1);
bar = new Solenoid(slot, port2);
System.out.println("Double MySolenoid enabled on slot " + slot + " and ports " + port1 + " and " + port2);
}
/*
* Extends the solenoid
*/
public void extend() {
foo.set(true);
if(doublek) {
bar.set(false);
}
}
/*
* Retracts the solenoid
*/
public void retract() {
foo.set(false);
if(doublek) {
bar.set(true);
}
}
/*
* Gets the state of the first solenoid
*/
public boolean get() {
return this.foo.get();
}
/*
* Gets the state of the other solenoid
*/
public boolean getOther() {
boolean eggs = bar.get();
return eggs;
}
}
|
|
#4
|
||||
|
||||
|
Re: Java Pneumatics
Thank you! Those both were very helpful!!!!
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|