For the integration with Arduino, I made a very simple code to make the linear actuator work. As I said before, Arduino is a very flexible device that allows you to implement almost anything you wish most easily.
The code moves the servomotor from 0 to 180 degrees back and forth in a loop. As soon as the code is launched, it will start moving.
Code
#include <Servo.h>
// Define the pin to which the servo motor is connected
#define SERVO_PIN 9
// Create a Servo object
Servo myServo;
void setup() {
// Initialize the servo motor on the specified pin
myServo.attach(SERVO_PIN);
}
void loop() {
// Move the servo motor from 0 to 180 degrees in 1 degree increments
for (int angle = 0; angle <= 180; angle++) {
myServo.write(angle); // Send the angle to the servo motor
delay(15); // Wait for 15 milliseconds before changing the angle (adjust as necessary)
}
// Move the servo motor from 180 to 0 degrees in 1 degree increments
for (int angle = 180; angle >= 0; angle--) {
myServo.write(angle); // Send the angle to the servo motor
delay(15); // Wait for 15 milliseconds before changing the angle (adjust as necessary)
}
}