const int pinRelayA = 8; const int pinRelayB = 9; void setup() { // initialize relay pins pinMode(pinRelayA, OUTPUT); pinMode(pinRelayB, OUTPUT); // preset relays to LOW digitalWrite(pinRelayA, LOW); digitalWrite(pinRelayB, LOW); } void loop() { extendActuator(); delay(20000); retractActuator(); delay(20000); stopActuator(); delay(5000); } //Set one relay one and the other off //this will move extend the actuator void extendActuator() { digitalWrite(pinRelayB, LOW); delay(250); digitalWrite(pinRelayA, HIGH); } //Set one relay off and the other on //this will move retract the actuator void retractActuator() { digitalWrite(pinRelayA, LOW); delay(250); digitalWrite(pinRelayB, HIGH); } //Set both relays off //this will stop the actuator in a braking void stopActuator() { digitalWrite(pinRelayA, LOW); digitalWrite(pinRelayB, LOW); }