View Single Post
  #3   Spotlight this post!  
Unread 18-01-2014, 11:49
fsilberberg fsilberberg is offline
WPILib Developer
AKA: Fred Silberberg
FRC #0190
Team Role: Alumni
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Redmond
Posts: 146
fsilberberg has a spectacular aura aboutfsilberberg has a spectacular aura aboutfsilberberg has a spectacular aura about
Re: Pneumatics Coding

While you certainly can go with a fully manual method like Bennett has suggested, WPILib will take care of most of that for you. This is all that you really need to do for the compressor.

Code:
Compressor compressor = new Compressor(1, 2);
// 1, 2 are locations of your limit switch and compressor relay, respectively 
compressor.start();
This will start the compressor and run it until the pressure switch has been hit. It will start back up again once the switch turns off again.

I recommend putting this in your main Robot class, where the compressor is declared as a class variable and you initialize and start in your robotInit() method. You can also create a pneumatics subsystem, and have its default command run the compressor.start() method in the initialize() method.

For operating solenoids, the WPILib documentation has an example, you can find that here:
http://wpilib.screenstepslive.com/s/...ders-solenoids.
If you have any more questions, feel free to ask.
Reply With Quote