View Single Post
  #5   Spotlight this post!  
Unread 05-02-2013, 21:14
Kusha's Avatar
Kusha Kusha is offline
Crimpin' ain't easy
AKA: Kusha Gharahi
no team (Looking for a team)
Team Role: College Student
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Dallas, Texas
Posts: 207
Kusha is a jewel in the roughKusha is a jewel in the roughKusha is a jewel in the roughKusha is a jewel in the rough
Re: Programming the Air Compressor and Pressure Switch

How we did it was we made a compressor object.

Compressor myCompressor = new Compressor(1,1); //the first number being the digitalIO port for the compressor, and the second being the relay port the spike is plugged into

And then in operatorControl() and where ever else before you start looping do myCompressor.start();

If that doesn't make sense please tell me and I'll clarify.

Also we had a problem where our code was correct but the ribbon cable from the c-rio to the sidecar was not working, and when we replaced that it worked.

EDIT: example
Code:
package edu.wpi.first.wpilibj.templates;


import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.Relay;
import edu.wpi.first.wpilibj.SimpleRobot;

public class RobotTemplate extends SimpleRobot 
{

    private int spikePort = 1;
    private int compressorPort = 1;

    private Compressor airCompressor;

    public void robotInit()
    {
        airCompressor = new Compressor(compressorPort, spikePort);
    }
    
    public void autonomous() 
    {
        System.err.println("Entering autonomous:");
        airCompressor.start();
        while(isEnabled()) 
        {
           
        }
    }
    
    public void operatorControl() 
    {
        System.err.println("Entering teleop:");
        airCompressor.start();
        while(isEnabled())
        {
          
        }
        
    }
   
   public void test()
   {
       System.err.println("Entering Test:");
   }
}
__________________
“Be the change that you wish to see in the world.”

― Mahatma Gandhi

Last edited by Kusha : 05-02-2013 at 21:26.
Reply With Quote