Button released callback

Hi, I tried to hook a callback to the button release, but somehow didn’t work…

BTW I’m using Pro C++ competition template.
If I press and release the L1 button, it will display something on the screen, but it won’t spin the claw motor…

void button_released_callback() {
    Brain.Screen.print("TEST CALLBACK");

    ClawMotor.spin(vex::directionType::fwd, 30, vex::velocityUnits::pct);

void usercontrol( void ) {

  while (1) {
  . . . .

Can anybody advise what went wrong?


I did try… same result… but it’s a callback right, so only need to be set once, instead of being checked continously like button pressing.


What else is in the user control loop? I would guess there is something there that is stopping the motor.

Also, the callback definitely does not belong inside the loop. It only needs to be called once.

1 Like

Yes it needs to be called once but if it’s not inside the loop, it will be read once and if it’s not true, it will be skipped over and never read again. Once usercontrol is run, the code “gets stuck” in the while loop. Anything outside of it and before it is literally read once and then completely forgotten. If, however, you left it as such, to get it to be checked you would have to call the function inside of the while which causes its own complexities. Putting it in the while loop just checks for if the button is being pressed, it doesn’t call the function unless the check (the button being released) is true.

Can you show what you have in the while loop? Are you sure you’re not setting the claw motor to something else during the while loop that would cause it to not move?

lmao love the name, didn’t realize what it said for like a whole 2 mins

You need to have parentheses on the end of a function call:


No u have to give it a function pointer not the function name. Also, he said that the lcd did display something meaning the function was activated. The problem is about the motor not spinning

91364T, you’re confounding the pressed/released and pressing functions. Once you call the pressed/released function, the callback is set and does NOT need be be called again. The only time you would need to call pressed/released multiple times is if you wanted to change what function the callback uses.

Since the text showed up on the brain, we know the callback is working. The callback and the loop run concurrently, which means there is likely something in the usercontrol loop that is causing the motors to stop, which would more than likely be the drive control logic.

1 Like

Got it, we’ll check if there’s any motor-stopping functions that interferes with this.