VCS V5 deadzone?


if(Controller1.Axis3.value()>15){}

does not work. How would I go about making a controller deadzone?

You almost have it right.
Instead, you need to use the absolute value of the joystick channel.


if(abs(Controller1.Axis3.value())>15){}

Alternatively, you can use the ternary operator to make a line like this:


joystickAxis3 = Controller1.Axis3.value();
joystickAxis3 = abs(joystickAxis3) > 15 ? joystickAxis3 : 0;

You could also use an if statement


joystickAxis3 = Controller1.Axis3.value();
if(abs(joystickAxis3) < 15) joystickAxis3 = 0;

1 Like

in terms of responsiveness, which method would you reccomend? I remember on the old robotc we used an if statement

They all do the exact same, and there is not much of a difference, but I prefer the ternary approach, as it allows for some good code neatness.


const int deadZone = 15;
int joystickAxis3 = 0;
int joystickAxis1 = 0;
while(true)
{
    joystickAxis3 = Controller1.Axis3.value();
    joystickAxis1 = Controller1.Axis1.value();
    joystickAxis3 = abs(joystickAxis3) > deadZone ? joystickAxis3 : 0;
    joystickAxis1 = abs(joystickAxis3) > deadZone ? joystickAxis1 : 0;
    setBasePower(joystickAxis3 + joystickAxis1, joystickAxis3 - joystickAxis1);
    sleep(20);
}

1 Like

I think I understand now, thank you! What coding studio are you guys using? Thinking about swapping to RMS because the other coder and I use multiple devices, but cell connection can be spotty in Hawaii and we’ve had to change things at comps in the past.

I am an avid PROS user, but I understand that it can be a bit daunting and confusing for beginners.
I would recommend RMS over VCS for sure.
If you do choose to try PROS, it is worth it to read through this excellent tutorial series www.learncpp.com
Good luck!

Can you use this in reverse as well?

It is best not to revive old threads. I would hope you don’t do this again.

@DRow