Code misbehaviour when linear actuator to the circuit
Consider the inrush current of the actuator, does it drag the voltage of power supply down to unacceptable levels for MCU?
Another thing to consider is a flyback diode across actuator terminals as this device is most probably inductive in nature and switching it off causes large voltage spike in opposite direction than your supply.