Hi,
I am trying to code a claw so it always closes with motors at 25 power. Pretty much, I want it so when you open the claw, there is a 0.25 second delay to when it automatically closes. When i put the wait command in there, it delays the entire bot. I am using Vex Cortex for RobotC.
if(vexRT[Btn8U]){
motor[Claw] = 127;
}else{
motor[Claw]=-25;
}
Try putting the claw control code in its own task. Something like this.
task clawTask() {
int delay = 0;
while(1) {
if(vexRT[Btn8U]) {
motor[Claw] = 127;
delay = 25;
}
else {
if(delay-- <= 0) {
motor[Claw]=-25;
delay = 0;
}
}
wait1Msec(10);
}
}
task main()
{
startTask( clawTask );
while(1) {
// drive code
wait1Msec(10);
}
}
Oops, never mind my response. My dumb idea would have kept the robot from seeing the rest of your code. jpearman has the correct way.
I showed one way, there are others. You could also use similar code in a single task.