#include <VarSpeedServoRA4M1.h> 
 
VarSpeedServoRA4M1 myservo;  // create servo object to control a servo 
// A maximum of twelve servo objects can be created

const int servoPin = 9;  // the digital pin used for the servo

void setup() { 
  myservo.attach(servoPin);  // attaches the servo on pin 9 to the servo object
  myservo.write(0,127,true);  // set the servo to its initial position at fast speed, wait for completion
} 

void loop() {
  // write(degrees 0-180, speed 1-255, wait to complete true-false)
  /* On the RC servos tested, speed differences above 127 
     cannot be noticed due to the mechanical limitations of 
     the servo. However, feel free to experiment with the 
     speed value that best suits the response of your servo 
     based on its mechanical and electronic characteristics 
  */
  myservo.write(180,127,true);  // move the servo to 180, fast speed, wait until done
  myservo.write(0,30,true);  // move the servo to 0, slow speed, wait until done
}