Problem with the compressor class

Hey, I am from team 4590.

We are having trouble with the compressor- it does nothing.
The pressure switch is connected to DigitalInput 1 and the Spike to Relay 2.
This is our full simple code:

note: when we use the Relay.Set() function (and don’t use the Compressor class at all) the compressor works.

#include "WPILib.h"
class RobotDemo : public SimpleRobot
	Joystick stick;
	Compressor comp;


	void Autonomous(void)

	void OperatorControl(void)
		while (IsOperatorControl())
	void Test() {



How is the pressure switch wired?

I believe the problem is that you won’t have any effect on things if you do your comp.Start() from the constructor - RobotDemo(). It is much more normal to see the starting of the compressor at the beginning of OperatorControl() outside of the while loop. And if you need the compressor in Autonomous, you would also call comp.Start() in the beginning of Autonomous().


Our code calls compressor start in the robot class constructor. It works fine. Compressor takes time to charge up the air tanks so you would want to start the compressor as soon as possible. If not the robot constructor, it should be at least the beginning of RobotInit.

Thank you for answering.

I have started the compressor in the OperatorControl() and it worked, but then I tried again to start it in the ctor and it also worked.

I have tried to look for the problem and I saw that it only works when I instantiate a RobotDrive. Can it be or is it just a coincidence?

If you digitital side car is not properly wired, I could see trying to run multiple PWMs cause a problem with reading the pressure switch.

It turn out one of the wires of the pressure switch was not connected properly.
Once we fixed it the Compressor started and stopped as expected.

Thank you for your help.