Trying to fix the code...
#include <Servo.h>
#include <Bounce2.h>
//defines
Servo myservo; // create servo object to control expansion servo
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
#define servoPin 3 //~ PWM for servo
#define ButtonSPin 2 //input button for expansion servo
int ButtonSState = 0;
int buttonSPushed = 0;
int angle =0; // initial angle for servo
int angleStep =30;
const int minAngle = 0;
const int maxAngle = 90;
void setup() {
myservo.write(0);
myservo.attach(servoPin); // attaches the servo on pin 3 to the servo object
pinMode(ButtonSPin,INPUT_PULLUP);
//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() {
//servo control
if(digitalRead(ButtonSPin) == LOW){
buttonSPushed = 1;
}
if( buttonSPushed ){
// change the angle for next time through the loop:
angle = angle + angleStep;
// reverse the direction of the moving at the ends of the angle:
if (angle <= minAngle || angle >= maxAngle) {
angleStep = -angleStep;
buttonSPushed = 0;
}
myservo.write(angle); // move the servo to desired angle
delay(100); // waits for the servo to get there
}
//LA Control
// 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
}
}