I don't like how my servo quickly jumps to the default middle position, so I commented out the line where
DEFAULT_PULSE_WIDTH is set in
//servos[this->servoIndex].ticks = usToTicks(DEFAULT_PULSE_WIDTH);
Unfortunately while this stopped the servo from moving on execution of
attach, the position of the servo is now showing up as
Just running the following in
setup() is enough to generate the bug:
int servo_pin = 53; servo.attach(servo_pin); Serial.print("Initial position: "); Serial.println(servo.read()); //returns -52
This last line returns
-52 no matter what position the servo is actually in, which has bad consequences (its initial movement is way off).
Note I get the same behavior when I set the
I am using a Mega -- an Elegoo clone -- on Windows 10.
Note I got the ideas for stopping the servo from moving on initialization from these threads: