todbot/ServoEaser

Change the start position from 90° by default

Opened this issue · 1 comments

Hello todbot,
I would like to change the StartPos in the code ServoEaser0ManualEasing.ino (not 90° by default).
I tried to add the start position in the servoEaser.begin( servo1, servoFrameMillis ) method.
In ServoEaser.h I changed the method from void begin(Servo s, int frameTime); //, int startPos); to void begin(Servo s, int frameTime, int startPos);
However, the code shows me errors or does not execute.
What am I doing wrong? I would be very grateful if you could help me with my problem.
Thank you very much!
-Tobias Haag-

When calling servoEaser.begin, the ServoEaser reads the current position of the servo object. So you need to call write on the servo object before calling servoEaser.begin.

void setup()
{
  Serial.begin(19200);
  Serial.println("ServoEaser0ManualEasing");

  servo1.attach( servoPin );
  servo1.write(160); // set the starting position to 160 degrees
  servoEaser.begin( servo1, servoFrameMillis ); 

  Serial.println("moving to 20 degrees over 2 seconds");
  servoEaser.easeTo( 20, 2000);
}