Function pressed driver control

Does anyone know how to program the function “pressed” in drivercontrol (vex v5 code pro).
For example: if id like a motor to rotate a certain number of rotationunits or degrees, how would that be done? (Not print on brain screen)

Welcome to the VEXForum @falasteeni!

https://api.vexcode.cloud/v5/html/classvex_1_1controller_1_1button.html#a601e90630490c40d5dd1d662db1b0888

The search bar could probably yield quite a few answers, here is one of the better threads

3 Likes

Thank you so much @trontech569 ! Unfortunately we’ve already consulted this thread, yet we still can’t figure out how to make it work.

Our team is also having trouble with this. Whenever we try to use the line of code “Controller.Button.pressed()”, there’s an error one way or another. I checked, I’m not missing any brackets or anything. We’re at a loss.

1 Like

Hmmm. Well, the motor.rotateFor(); command might do the trick.

https://api.vexcode.cloud/v5/html/classvex_1_1motor.html#a9d60dc336810ea4d8aef35ee042f0d68
Making sure to use the wait for completion parameter.

I mean, you could probably do something like:

motor.spin(controllerAxisValue)

if(controller.buttonwhatever.pressing){
motor.rotateFor(whatever, wait for completion);
}

Using the pressed command you could probably do:

void pressedfunction (){
motor.rotateFor(whatever, wait for completion);
}

int main() {
    Controller.ButtonA.pressed(pressedfunction);//every time Button A is pressed function() is run
    while(true){//so program doesn't exit
        vex::task::sleep(25);
    }
}

Not sure about that second code though, I haven’t tried much with the pressed command.

If you have specific code that is not working you could also post it.

4 Likes

god bless your soul
you made it clearer

1 Like