Servo "park" angle

In using the Servo library, I have found that if I send no commands to the library for a portion of time (e.g., while waiting for the user to press a button), after about 1 second, the servo moves to a "park" angle. I have also found that if I set a servo angle before I attach to the servo object, that angle becomes the "park" angle.

I looked over the GitHub library code, and I don't see where this "park" position is set or persisted. So, the behavior is confusing (is there some other source for this library?).

What I'd like to be able to do is to set this "park" position at any time, so when the servo object hasn't been written to for a while, the servo doesn't move to an unexpected position.

Is there a way to do this?

Thanks,

Mark

The servo should stay at whatever position you have directed it to go to, regardless of how long you wait for user input, AS LONG AS interrupts are enabled.

If you are waiting for input in an interrupt service routine, STOP doing that.

If you want help understanding why your code is doing what it is point, POST YOUR CODE!

I've never observed this behaviour in any code I've written.

You can certainly write before attach.

Thanks for the feedback! After a bit of digging, I figured out that what was going on was that I was exceeding the current supplied by the USB interface (other peripherals attached). When I move over to battery power, everything works fine. So, I think the excessive power draw was causing the processor to reset, and thus the servo position to reset.

Mark

Where are the servo and other peripherals powered from ?

The Arduino 5V pins have limited ability to provide power and power hungry peripherals should be powered from an external source and not from the Arduino voltage regulator.

The Servo object defaults to 1500 microseconds (90°) until you set it to another position. That is why not initializing at startup caused the servo to move to 90° on reset and initializing at startup caused the servo to move to the initialized position on reset.