How to use the pressed command on my vex v5 controller

For my team’s robot, I want to code the controller to change how fast it turns (setTurnVelocity) by +5(ButtonUp) or -5 (ButtonDown) when I click a button (just mentioned). this is for the purpose of making it easier to control while picking up block with our arm. I have tried searching many times and couldn’t find anything, my current code is:

void Drivetrain.setTurnVelocity(75, percent);
Controller1.ButtonUp.pressed(Drivetrain.setTurnVelocity(75, percent));

without that first line, it returns the error (with (Drivetrain.setTurnVelocity(75, percent) in red):

[clang] Cannot initialize a parameter of type ‘void (*)()’ with an rvalue of type ‘void’

with the first line, it returns the error messages (with Drivetrain in the first line in red):
[clang] variable has incomplete type ’ void’
[clang]expected ’ ; ’ at end of declaration (fix available)

I have searched those error messages many times and found nothing I didn’t already know in my limited knowledge of C++ (aka I don’t know anything except from what I have learned by stumbling around during the past month of robotics, I do know some python though)

any help would be nice, along with checking out my previous topic asking for basically the same thing with less detail that everyone seems to see, but not answer

EDIT: this is for Vex EDR

Can you post your code in its entirety?

2 Likes

I believe, we answered this question in another topic: How to change turn velocity by 5% with a button press

The suggestion was to use simpler button.pressing() method instead of more advanced button.pressed(), which needs callbacks and separate tasks.

See button reference: https://api.vexcode.cloud/v5/html/classvex_1_1controller_1_1button.html