how to make servo save home angel

Hi every one

I have a project for packaging and I use servo as a final gate
but every day this servo forget its angel and I have to edit the angel daily

could you help me to save home angel of servo and fix this problem

you will find my Arduino code and I will paste link on youtube for servo gate

thank you so much

#include <Servo.h>

Servo myservo; // create servo object to control a servo
void setup() {
//configure pin2 as an input and enable the internal pull-up resistor
pinMode(12, INPUT_PULLUP);
pinMode(13, OUTPUT);
myservo.attach(9); // attaches the servo on pin 9 to the servo object
TIMSK0=0;

}

void loop() {
//read the pushbutton value into a variable
int sensorVal = digitalRead(12);

//print out the value of the pushbutton

// Keep in mind the pullup means the pushbutton’s
// logic is inverted. It goes HIGH when it’s open,
// and LOW when it’s pressed. Turn on pin 13 when the
// button’s pressed, and off when it’s not:
if (sensorVal == HIGH) {
myservo.write(180);
digitalWrite(13, LOW);
} else {
myservo.write(90);
digitalWrite(13, HIGH);
}
}

The word you need is "angle" not "angel". Your program only has two angles, 90 and 180. Exactly what in that program do you have to edit daily?

It may be that the problem is with your mechanical setup. I can't see anything useful from that video but perhaps whatever is connected to the servo is actually slipping round, probably because you are driving the servo further than the "gate" can physically move.

Steve

sounds like your servo doesn’t make complete 90 angel turn

change 180 to 190 , 90 to 100

then realign your mechanical setup