Joystick axis controlling a motor

So, when I move the axis on my joystick, the motor I’m trying to control doesn’t spin, but when I press button 1 it does spin:

m_Joystick.axisGreaterThan(m_Joystick.getYChannel(), 0).onTrue(
            CommandUtililty.moveX(
                m_Joystick.getY()
            )
        ).onFalse(
            CommandUtililty.moveX(0)
        );
        m_Joystick.axisLessThan(m_Joystick.getYChannel(), 0).onTrue(
            CommandUtililty.moveX(
                m_Joystick.getY()
            )
        ).onFalse(
            CommandUtililty.moveX(0)
        );

How can I make it so that the motor is controlled by the pitch axis of the joystick? Thanks!!

You’re looking to get the axis values, the getX and getY buttons get the literal “X” and “Y” buttons on the controller.

the m_joystick variable is a CommandJoystick object and so there aren’t any x or y buttons on the physical controller.

I don’t really understand what this code is trying to do. Isn’t that whole block functionally the same as:

CommandUtililty.moveX(m_Joystick.getY());

EDIT: I guess this is necessary to get triggers for command-based programming? Seems overly complicated, but maybe I’m too new at this.

Have you checked the joystick inputs on the Driver Station to make sure they correspond to what you think they should?

Looks like you could set the channel for the y axis, so maybe it’s not set correctly.

yes I tried to set the y channel as the axis that moved in the driver station. No luck

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.