My team and I have been trying to get the compressor programmed, but it usually clicks when the light is green switching to red for a split second before going back to normal. It does it almost randomly, and does seem to be linked to our code. We have been using a simple on/off trigger so that we can turn the relay on and off, but the clicking happens when the spike should be on. our code is:
the lighting for a spike is as follows:
for a motor:
Orange - OFF / Brake Condition (default)
Green - Motor rotates in one direction
Red - Motor rotates in opposite direction
Off - OFF / Brake Condition
for a solenoid:
Orange - Both Solenoids OFF (default)
Green - Solenoid connected to M+ is ON
Red - Solenoid connected to M- is ON
Off - Both Solenoids ON
Basicly when it switches from green to red the spike is reversing the direction.
from the code what appears to be happening is that it starts off as isOn = false. Then it enters the first part of the code and isOn changes so now isOn = true. then it looks like the program then goes into the next part of the code and then changes it back to false. Are you sure that you are not looping it because the first time it would go through it would do the first half of the code and the next time through it would switchback.