C++ Coding Problem

Controller1.ButtonUp.pressed(velocityIncrease(120));
image

int main() {
  vexcodeInit(); // Initializing Robot Configuration. DO NOT REMOVE!
  Motor1.setVelocity(motorVelocity, rpm);
  Controller1.ButtonUp.pressed(velocityIncrease(120));
  Controller1.ButtonR2.pressed(motorBackwards);
  Controller1.ButtonL2.pressed(motorBackwards);
  screenUpdate();
}
void velocityIncrease(int num) {
  motorVelocity = motorVelocity + num;
  if (motorVelocity > 600) {
    motorVelocity = 600;
  }
  Motor1.setVelocity(motorVelocity, rpm);
  screenUpdate();
}

New to this so just trying to figure out whats wrong

The error is telling you that Controller1.ButtonUp.pressed function takes an argument that is a function that returns void and accepts no parameters. Notice that Controller1.ButtonR2.pressed(motorBackwards) works, presumably because you have defined it as:

void motorBackwards() {
// Code here
}

The fact that your velocityIncrease function takes an integer parameter is the problem.

2 Likes

Is there a way I can add a parameter into it one way or another?

You could try using lambdas by replacing

velocityIncrease(120)

with

[](){ velocityIncrease(120); }
3 Likes