Servo Control with force sensors

Hi Guys im new to Arduino and this is my first post.

Im working on a project for college where im designing a robotic hand that i will be controlling through simulations.

I have a good idea of how im going to do it but im really stuck on one part - the grip control.

ive got force sensors telling the hand when to stop squeezing, and im having a devil of a time with the if commands. when the hand grips something hard enough i want the motors to stop squeezing and just hold it, but they just go on through the programme and then follow the if command once done

this is the code im using - im first doing a simulations with one motor, i want it to go through a series of movements and as soon as i press on the sensor hard enough it stops, and moves to 45degrees

#include <Servo.h>

int sensorPin = 0;
int sensorValue;
Servo servoClaw;

void setup()
{
servoClaw.write(0);
servoClaw.attach(9);
}

void loop()
{
sensorValue = analogRead(sensorPin);
if(sensorValue<450){

openClaw();
delay(2000);
closeClaw();
delay(2000);
}

sensorValue = analogRead(sensorPin);

if(sensorValue>450){ // i just want the movements to stop as soon as i press on the force sensor and move to 45, but instead it finishes going from 0-180 and then goes to 45
servoClaw.write(45);
}
}

void openClaw(){
servoClaw.write(0);
}

void closeClaw(){
servoClaw.write(180);
delay(2000);

}

if anyone could give me a hand with this id much appreciate it

if(sensorValue>450){ // i just want the movements to stop as soon as i press on the force sensor and move to 45, but instead it finishes going from 0-180 and then goes to 45

It does that because you told it stick its head in the sand and ignore the force sensor for a while.

  openClaw();
  delay(2000);
 closeClaw();
 delay(2000);

Move to 0. Wait a second. Move to 180. Wait 2 seconds. Wait 2 more seconds. Then,

  if(sensorValue>450){     // i just want the movements to stop as soon as i press on the force sensor and move to 45, but instead it finishes going from 0-180 and then goes to 45
      servoClaw.write(45);
  }

See if is necessary to go to 45, and go there if it is.

You need to dump the openClaw() and closeClaw() functions, now that you know the claw works.

You need a function that closes the claw in small increments, testing the sensor at the end of each movement, just like a human does.