I made a window system, which can be opened and closed by a servo motor.

Here is the code, which is mostly copied from the servo motor exercise.

const int SERVO_PIN = 9;
=======================================================================
Servo wiggling_servo;
void linear_move(int start, int end, float speed = 60.0)
{
const int interval = 20;
float step = speed * 0.001 * interval;
float angle = start;
do {
wiggling_servo.write(angle); // update the servo output
delay(interval); // pause for the sampling interval
if (end >= start) {
angle += step; // movement in the positive direction
if (angle > end) angle = end;
} else {
angle -= step; // movement in the negative direction
if (angle < end) angle = end;
}
} while (angle != end);
// Update the servo with the exact endpoint before returning.
wiggling_servo.write(end);
}

void setup()
{
// Initialize the serial UART at 9600 bits per second.
Serial.begin(9600);

// Initialize the Servo object to use the given pin for output.
wiggling_servo.attach(SERVO_PIN);
}

// Run one iteration of the main event loop. The Arduino system will call this
// function over and over forever.
void loop()
{
linear_move(0, 60, 60);
linear_move(60, 0, 60);
}