How to set V5 motors to 25% velocity in Vex coding studio

I just need help setting up a thing to where i can set my motors to 25% velocity in vex coding studio

[motorname].setVelocity(25,velocityUnits::pct);

1 Like

yea thats what i do but when i press the B button that i have programed to start the slow_drive function it doesnt work the coding i have set up to activate the slow drive function is

while(true){
Controller.ButtonB.pressed(slow_drive);
}

i dont know why it doesnt work i had the exact same code for my bot last year and it worked perfectly fine but now it doesnt work i cant upload my full code at the moment but i will have it uploaded by 12:35 today and mabey i could get some more help if possible

With that structure, you actually don’t need the while loop. It would just go into the driver control loop. Post your code when you can and i’ll take a look.

1 Like

ok will do thanks mate

2019-2020 base drive program.vex (4 KB)

there’s my coding file i could use all the help i can get tbh

This registers an event handler. It only needs to be done once, and doesn’t need to be put in a loop.

This only works if spin has been called since the last stop or program start. Otherwise, all it does is set the default velocity for any commands that don’t specify a velocity.

1 Like

so how do i go about it to where it works

Just go to the documentation library on the vex website

You can find all of the commands and what they do here

  • Remove the if statement, the callbacks don’t need to be in a statement/loop
  • Considering your use case, you should change the 'setVelocity’s to spin in your functions.