Claw is timed and isn't consistent

I’m designing a robot arm (which you wear) using Vex 2.0 Cortex and Natural Language PLTW.

I made a code that when started it works fine, but as time goes on the motor gets “weaker” and wont respond when pressing the limit switch. I programmed the bot to open and close when pressing or releasing the limit switch.

If anyone would like to also, how can I make it so that the light switch also works alongside the claw?

Also whenever I make the robot “autonomous” the flashlight gets super weak, I don’t know why, any help? Thanks.

Code:

----------------------------------------------------------------
#pragma config(Sensor, in2,    light,          sensorAnalog)
#pragma config(Sensor, dgtl1,  limitSwitch,    sensorTouch)
#pragma config(Motor,  port1,           flashlight,    tmotorVexFlashlight, openLoop, reversed)
#pragma config(Motor,  port3,           clawMotor,     tmotorVex393_MC29, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()

{
	while (1==1){
	untilTouch(limitSwitch);
	{
	motor[clawMotor] = 127;
	}
	untilRelease(limitSwitch);
	{
	motor[clawMotor] = -127;
}
}


	while(1==1){
	if(SensorValue(light) >=400)
	{
	turnFlashlightOn(flashlight, 127);
	}
	else if(SensorValue(light) <400)
	{
	turnFlashlightOff(flashlight);
	}
}
}
type or paste code here

You are tripping the PTC in the motor. It is a device that stops the motor brushes burning out if it gets jammed.
Really, you need a potentiometer or another sensor to help the claw hold position without full power when it is closed. In practice, you can probably close the claw at full power (127 or -127) for like 2 seconds to make sure it is shut, and then set it to 50 or -50 power to just hold it there without tripping the PTC afterwards.

The 2nd while loop in your code will never run because the code stays in the first loop indefinitely.