how to break out servo.write(angle) after it reach the angle? I used a servo as a grabber so I don't know the angle I need specifically.I need it to break the serve.write(angle) when the grabber holds something.
I used a simple code 

#include &lt;Servo.h&gt;
Servo myservo; 
void setup() {
  myservo.attach(9); 
}
void loop() {
  myservo.write(100);                  
  delay(500);
  myservo.write(50);                  
  delay(500);                           
}


when it holds anything it deos not return to the small angle until I remove the obstacle from its way.
You change the angle in small increments until the sensor triggers:

bool closing = false;
bool openeing = false;
int angle;

void loop(){

    //read touchSensor

    if(sensorHit){
        closing  = false;
    }
    if(closing){
        if(angle &lt;= minAngle) closing = false;
        angle -= 1;
        myservo.write(angle);

    }

    if(opening){
        if(angle &gt;= maxAngle) opening = false;
        angle += 1;
        myservo.write(angle);

    }

}


The to start moving the grasper you set opening or closing to true. You can also add some trigger logic in the places where they get set back to false for the next movement if applicable.