Isn't that the point of this line?
//use the writeMicroseconds to set the linear actuators to their default positions
LINEARACTUATOR.writeMicroseconds(linearValue);
I'm not sure I understand your statement.
See below the linear actuator code that does work by itself. I merely copied it into the servo code that also worked by itself.
//Includes
#include <Servo.h> //Servo Library
#include <Bounce2.h> //Debouncing Library
//Defines
const int LINEAR_ACTUATOR_PIN = 5; //Linear Actuator Digital Pin
const int BUTTON_PIN = 4; // the number of the pushbutton pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
Servo LINEARACTUATOR; // create servo objects to control the linear actuator
int linearValue = 1000; // current positional value being sent to the linear actuator.
Bounce debouncer = Bounce(); // debouncing object
void setup()
{
//initialize servo/linear actuator objects
LINEARACTUATOR.attach(LINEAR_ACTUATOR_PIN, 1000, 1500); // attaches/activates the linear actuator as a servo object
// initialize the pushbutton pin as an input with internal pullup:
pinMode(BUTTON_PIN, INPUT_PULLUP);
// After setting up the button, setup the Bounce instance:
debouncer.attach(BUTTON_PIN);
debouncer.interval(5); // interval in ms
//use the writeMicroseconds to set the linear actuators to their default positions
LINEARACTUATOR.writeMicroseconds(linearValue);
}
void loop()
{
// Update the Bounce instance :
debouncer.update();
// Get the updated value :
int buttonValue = debouncer.read();
if ( debouncer.fell() ) // if the button was pressed
{
if (linearValue == 1000) //if the box is set to close
{
linearValue = 1500; //set box to open
}
else if (linearValue == 1500) //if the box was set to open
{
linearValue = 1000; //set box to close
}
}
LINEARACTUATOR.writeMicroseconds(linearValue); //use the writeMicroseconds to set the actuator to the new position
}
}