Deadpan variable not working

With the EXP blocks program, I understand the Deadpan variable will help stop joystick drift on a controller. We have used this and it does indeed work.

Today, another robot started to drift and I inserted the deadpan variable in two different locations. One position is where you see it in this screenshot. The other spot I placed it was inside the Forever loop. Neither location stops the drifting all together.
I appreciate the help.

Where exactly did you insert your variable? I can only see a declaration and value assignment.

As noted above, you are declaring the variable, but you never use it for anything.
In VEXcode EXP, go to File, then Open Examples. Now go to Sensing at the top, then scroll all the way down to find the Tank Drive Control example which uses a deadband.

It looks like this:

You’ll see that there are two If/Else statements in this program, one of the left stick and one for the right stick.

The abs command is used in this case to remove negative values. When the joystick is in the middle, it is zero. When you push it up (or right) the value increases towards 100. When you push it down (or left) the value decreases towards -100. But in this case, we don’t want the - sign to be considered, so abs of controller 2 position will always return between 0 and 100, whichever way you push the stick.

We then compare that with the deadband variable. If the joystick value is greater than the deadband, then the motor speed is set. If the joystick is anywhere between zero and the deadband, then the motor is stopped.

Don’t forget, you should also calibrate your controller, this will also help eliminate creeping:

1 Like

Thank you. I am new to using variables and had forgotten about putting it into the actual code. Your example really helped.