To control the compressor, you just use the
Compressor class. You instantiate a single Compressor object, telling it which relay port is connected to the compressor and which Digital I/O port is connected to the pressure switch. You then call its Start() method.
That's it. Nothing more. You do not create a Relay object for it. You do not create a DigitalInput for it.
Take out everything in your code that you have put in to try to make the compressor work, and replace it with two lines in your initialization code:
Code:
Compressor *myCompressor = new Compressor(1, 5);
myCompressor->Start();
"1" is the Digital Input with the pressure switch. "5" is the Relay powering the compressor.
You could also make myCompressor a regular variable instead of a pointer and call the object's constructor as part of the RobotDemo constructor, but I'm not as comfortable as some people are with the requirements for what order things have to be specified.