Programming with time help

I’m trying to figure out how to program my intake to run for a certain amount of time (for autonomous) yet I keep running into issues like the intake running indefinitely. If anyone can help me out I would appreciate it!!

This is my program:

void Intake(int time){
LeftClaw.spin(directionType::fwd,60,percentUnits::pct);
RightClaw.spin(directionType::fwd,60,percentUnits::pct);
task::sleep(uint32_t(time));
LeftClaw.stop(brakeType::hold);
RightClaw.stop(hold);

You have the question marked as VEX IQ. The code looks like it in VEXcode V5 Text (which is for VEX EDR), is this the case?

What values are you passing to the function?

:bulb: Remember that task::sleep takes milliseconds

If this isn’t the problem we would probably need more code to determine the issue.

1 Like

If you want the intake to not run indefinitely, use the .stop() command to stop the rollers whenever u want it to stop

1 Like