You don't understand the difference between assignment of an existing
variable and declaring a new variable:
if (Extending == true && CurrentPosition > goalPosition ){
//we have reached our goal, shut the relays off
actuatorStop();
boolean Extending = false; ///////// WRONG!!!!!!
Serial.println("IDLE");
}
Declaring a new variable of the same name will do nothing. Assignment
(ie changing) an existing variable is just = ;
Specifying a type and a name is a declaration - creating a new separate variable.
So change those lines to :
Extending = false;
I also note a problem in your motor control routines:
void actuatorExtend(){
digitalWrite(relay1, HIGH);
digitalWrite(relay2, LOW);
}
void actuatorRetract(){
digitalWrite(relay1, LOW); // turn on one relay before
digitalWrite(relay2, HIGH); // turning off the other!!
}
void actuatorStop() {
digitalWrite(relay2, HIGH);
digitalWrite(relay1, HIGH);
}
You say the relays are active low - one drives forward, the other backward - thus
its presumably an error (short circuit?) if both are driven LOW.
So you always need to set one pin HIGH before the other goes low:
void actuatorRetract(){
digitalWrite(relay2, HIGH); // turn off before
digitalWrite(relay1, LOW); // turning on
}
You also may have the issue that both relays are on at power-up before the Arduino
gets going. If this does cause a hardware issue you should add physical pull-up
resistors to both relay inputs if they don't already have them.