Limiting servo angle

hello I have made a doorlock with a servo and I dont want the servo to rotate more than a point becouse if it moves back too much pulling the wire thats connected to the doorlock, it snaps the wire. >:(
it happens whenever the arduino restarts.

The best way to do that is to attach the servo arm in such a way that the maximum movement of the servo is at the limit of movement of the wire.



int startPosition = ?; // a position that won't snap the wire (90 is default which apparently does)
void setup(){

You can also use a heavy spring to add flexibility to the linkage.



You cannot guarantee that a servo won't go amok with code alone. If it is sufficiently powerful to cause damage to a delicate mechanism then you need a mechanical safeguard.