A simple test to help you isolate the problem:
Take a screwdriver or a short piece of wire and short the pressure switch (connect the two terminals). This will completely take the switch out of the picture. You'll see one of two results:
1. The compressor runs constant until you remove the short (keep an eye on the pressure gauge, don't let it get too high!).
2. You continue seeing the same behavior you saw before.
In the case of situation 1, you now know that the code is fine, and the problem is the pressure switch. This is because you gave the Digital Sidecar a constant signal from the switch indicating that you were below pressure.
In the case of situation 2, you know the issue is in your code. Look for a possible path where the relay is being turned off and then back to forward. For example, something like this:
Code:
relay.set(Relay.Value.kOff);
if (pressureSwitch)
{
relay.set(Relay.Value.kForward);
}
Also, please note that the commands don't have to be this close together... look at ALL commands sent to the relay and make sure you don't end up with a situation like this.