Keep previous position of a servo after power failure

Hi Friends,

I have MG 995 servo motors for my robot arm.
After any power failure all servo motors very very quickly get it's zero position.This is harmful to my mechanism.It may be brake down my robot's arm.I have read the Servo library,but,I couldn't find any function for get zero position when power up(I am not a expert of C :disappointed_relieved: ).So,Is this the nature of MG995 servo? :confused:

How can I keep previous position after power failure?

Thank in advance

You can write a previously stored position (or other default) before you perform the "attach" for a servo.
If you store the last position to EEPROM before switching off, you could retrieve that value.

#include <Servo.h>

Servo myservo;  // create servo object to control a servo

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object

void loop() {

I think you said like this,It gives a error.

exit status 1
'myervo' was not declared in this scope

It is not possible write a value before attach.

It is not possible write a value before attach.

You’re not trying spelling hard enough.

yes,I must agree with you.My English is not good.:slightly_frowning_face: :slightly_frowning_face: