Ease in-out - servo sweep

Hello.
I have a Nano and a Servo with an variant of sweep example. Now it is working fine but servo movements are linear. Do you know how can I add an ease in and out for make it more natural?
I see ServoEasing library but... I'm not understanding how to use it!
Thanks!

Actual code:

// initial delay
#define initDelayMinVal 2000
#define initDelayMaxVal 2800

bool DEBUG = 0;
#define wingMinVal 35 //30
#define wingMaxVal 150 //170
#define SERVOPIN 3
#include <Servo.h>
Servo servoali;
// int delayLoopVal = 15; //init
#define delayLoopMinVal 10
#define delayLoopMaxVal 15

// int pos = wingMaxVal; //posizione iniziale

void setup() {
  digitalWrite(LED_BUILTIN, LOW);
  servoali.attach(SERVOPIN);  // attaches the servo on pin 9 to the servo object
  if (DEBUG) (Serial.begin(9600));

  // close wings - hibernation mode
  servoali.write(wingMinVal); 
  randomSeed(analogRead(0));
  delay(random(initDelayMinVal, initDelayMaxVal)); // need it for give diversity
}

void loop() { 
  int delayLoopVal = random(delayLoopMaxVal - delayLoopMinVal + 1) + delayLoopMinVal; // need it for give diversity
if (DEBUG) (Serial.println("delayLoopVal =" + String(delayLoopVal)));

  int pos = random (delayLoopMinVal, delayLoopMaxVal); // default 15
  for (int pos = wingMinVal; pos <= wingMaxVal; pos += 1) { // goes from wingMinVal degrees to wingMaxVal degrees in steps of 1 degree
    if (DEBUG) (Serial.println("pos =" + String(pos)));
    servoali.write(pos);              // tell servo to go to position in variable 'pos'
    digitalWrite(LED_BUILTIN, HIGH);
    delay(delayLoopVal);                       // waits delayLoopVal ms for the servo to reach the position
    digitalWrite(LED_BUILTIN, LOW);
  }
  if (DEBUG) (Serial.println("== END WING UNFOLD =="));

  for (pos = wingMaxVal; pos >= wingMinVal; pos -= 1) { // goes from wingMaxVal degrees to wingMinVal degrees
    digitalWrite(LED_BUILTIN, HIGH);
    if (DEBUG) (Serial.println("pos =" + String(pos)));
    servoali.write(pos);              // tell servo to go to position in variable 'pos'
    delay(delayLoopVal);                       // waits delayLoopVal ms for the servo to reach the position
    digitalWrite(LED_BUILTIN, LOW);
  }
  if (DEBUG) (Serial.println("== END WING FOLD == "));

}

Your topic was MOVED to its current forum category which is more appropriate than the original

how do you define "ease in and out"?
that the delay between movements is proportional to the angle?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.