Using of velocities

hello my problem is about using the velocity of the motors. I want to use velocities of motors to trigger smt. how can I use the velocities

Hi, welcome to the forum! If I understand you correctly, you should just be able to use an if statement to check the velocity versus what will trigger the event. Please try to use plain English and clearly state your question so it’s a little easier to understand next time.

We are trying to use Motors velocitys to trigger brakes think like if somebody pushes our robot it will auto break it self. As I understand we can see the velocity changes when we spin the motors with hand

Ok. Cool. Very good idea. The lucky thing for you, is that vexcode has a command that will lock the motors when they are not in use. This means that all you have to do is set the “stopping mode” to “hold”. No tricky programming involved. If for some reason you do not want to be locked whenever you are stopped, consider an if-then-else statement so that you can press a button to lock your wheels. In text the locking mode is:


and in blocks it is

I believe the op may be asking for a way to activate a custom made brake, such as by using pneumatics to jam a static gear in the drivetrain gears.

For this use case, instead of using motor velocity, I would use motor efficiency. When the efficiency is low it means the motors are trying to move but can’t, such as when pushing a robot.
Example in vexcode (pros has a similar command):

if (Motor.efficiency() < 40) {
    // activate brake system…

Alternatively, you could also just press a button to activate the brake, which would prevent it activating when you don’t want it to.

er, no, efficiency is the ratio of input power to output power. from the source code.

      double efficiency;
      // avoid divide by 0
      if( inputPower == 0 )
        efficiency = 0;
      else {
        efficiency = (outputPower / inputPower) * 100.0;

now output power, and therefore efficiency, will be low (probably 0) if the motors can’t move, but it will also be low at other times.


ty for your answer now I wanna ask is how to use the code which like Controller1.Button(idk).pressing()
I need this to trigger smt again as I see you know kinda those things.