Start and Stop Stepper with Accel Library

For a start, an assignment in the middle of a function call is generally a bad idea. A similar problem is this:

if (a = 5)
  // do something

That assigns 5 to a, not tests if it is 5.


Similarly, something like:

      digitalWrite(relayPin, relayState = !relayState);

... has a side-effect of changing relayState. People might wonder if you meant to test rather than change it.


Your definitions are:

#define relayOn 8000                     //Amount of time the SSR stays on
#define relayOff 4000                    //Amount of time the SSR stays off

If relayState is currently relayOn, then negating it will not give you relayOff.

Negation is a boolean operation. If the original value is non-zero, the new value is zero, and vice-versa.

Thus:

relayState = !relayOn;  // relayState is now zero, not 4000