Autonomous for moving forward

can anyone show me code for moving a robot forward, for autonomous? I saw the other forums, but I still didn’t get the idea, since many people had different code. I also tried looking at the examples in vexcode text, but it had examples with drivetrain, and I don’t use drivetrain. Any example with the latest code would be helpful.

Thank you!

Is this for a drivetrain?

no, not for a drivetrain, thank you.

Do you want to use the built in encoders?

1 Like

ummm, no.What do you mean by the encoders? Is there a benefit to using them?

And can you post current code, so I can see exactly what to put?

Ok, i’ll try making the code right now, from my current knowledge, but I can’t promise no errors or logic errors, im very new to this. I’ll get onto it right away.

no,no just what you already have, like your driver control code

1 Like

oh ok, ill send that

int main() {
// Initializing Robot Configuration. DO NOT REMOVE!

// Deadband stops the motors when Axis values are close to zero.
int deadband = 5;

while (true) {
// Get the velocity percentage of the left motor. (Axis3)
int leftMotorSpeed = Controller1.Axis3.position();
// Get the velocity percentage of the right motor. (Axis2)
int rightMotorSpeed = Controller1.Axis1.position();

// Set the speed of the left motor. If the value is less than the deadband,
// set it to zero.
if (abs(leftMotorSpeed) < deadband) {
  // Set the speed to zero.
  LeftMotor.setVelocity(0, percent);
} else {
  // Set the speed to leftMotorSpeed
  LeftMotor.setVelocity(leftMotorSpeed, percent);

// Set the speed of the right motor. If the value is less than the deadband,
// set it to zero.
if (abs(rightMotorSpeed) < deadband) {
  // Set the speed to zero
  RightMotor.setVelocity(0, percent);
} else {
  // Set the speed to rightMotorSpeed
  RightMotor.setVelocity(rightMotorSpeed, percent);

// Spin both motors in the forward direction.

wait(25, msec);


this is tank drive control by the way.

any simple example code that you can paste, would be very helpful, thank you.

here’s a simple way to go forward

LeftMotor.setVelocity(whatever, pct);
RightMotor.setVelocity(whatever, pct);

vex::task::sleep(whatever, msec);

I needed help with this too, thanks

1 Like

thank you, can I also implement this into a function?

Is this also for vexcode

1 Like

it’s gross I will post a better example later

1 Like

While I was waiting, I made an autonomous using functions, can I show it to you for proof reading?

Its better then anything I can ask for. I understand so much now just from this code, thanks!

void driveForward( int t ) {
//code from before, instead of whatever, put t
//then call it in your autonomous