I have a linear actuator (http://www.firgelli.com/Firgelli_Technologies_PQ12_R_p/pq12-r.htm) that I want to be able to slow down. Right now, the shaft moves too quickly. I’m not sure how to do this. I was looking into varSpeedServo.h library but couldn’t implement it.
//Includes
#include <Servo.h>
//Defines
#define LINEARACTUATORPIN 9 //Linear Actuator Digital Pin
const int button1Pin = 4; // the number of the pushbutton pin
// variables will change:
int button1State = 0; // variable for reading the pushbutton status
Servo LINEARACTUATOR; // create servo objects to control the linear actuator
int linearValue = 10000; //current positional value being sent to the linear actuator.
void setup()
{
//initialize servo/linear actuator objects
LINEARACTUATOR.attach(LINEARACTUATORPIN, 1050, 2000); // attaches/activates the linear actuator as a servo object
// initialize the pushbutton pin as an input:
pinMode(button1Pin, INPUT);
//use the writeMicroseconds to set the linear actuators to their default positions
LINEARACTUATOR.writeMicroseconds(linearValue);
}
void loop()
{
// if the pushbutton is pressed set the linear value
button1State = digitalRead(button1Pin);
if (button1State == HIGH) {
// set the position value
delay(2000);
linearValue = 1050;
}
if (button1State == LOW) {
// set the position value
linearValue = 2000;
}
//use the writeMicroseconds to set the actuator to the new position
LINEARACTUATOR.writeMicroseconds(linearValue);
delay(3000);
}