V5 autonomous help

Hi I’m new to v5 and I need help on my autonomous.

Can you be more specific? What coding do you use?

1 Like

V5 text.

(20 characters)

If you want the forum to review your code then you should post it so we can help.

Below is the most popular autonomous function used during Tower Takeover. Use this with the default competition template.

//Define the motors you are using. 
//The right motor should spin opposite (reverse)
//Ref: motor( int32_t port, bool reverse )
motor leftMotor = motor(PORT1,false);
motor rightMotor = motor(PORT2,true);

void autonomous(){

  //Ref: spin( directionType dir, double velocity, velocityUnits units )
  //Drive forward for 3 seconds.
  leftMotor.spin(directionType::fwd, 50, velocityUnits::pct);
  rightMotor.spin(directionType::fwd, 50, velocityUnits::pct);
  wait(3,timeUnits::sec);

  //Stop
  leftMotor.stop();
  rightMotor.stop();
  wait(1,timeUnits::sec);

  //Drive backward for 3 seconds
  leftMotor.spin(directionType::rev, 50, velocityUnits::pct);
  rightMotor.spin(directionType::rev, 50, velocityUnits::pct);
  wait(3,timeUnits::sec);

  //Stop
  leftMotor.stop();
  rightMotor.stop();
}
1 Like