I am a relatively new programmer on a second year team. I was wondering if anyone knows if it is possible to program a window motor using the joystick buttons. What our team would like to do is to program our joystick so that when we press one button, the arm motor goes forward. When we press another button, we want the motor to go back. I do not know how to translate the relay outputs to a pwm output which would make the motor move. I tried writing an if statement that makes the pwm produce an output if a button is pressed, however nothing happens. I have performed countless searches for this information. The only threads I found talked about operating pnuematics using the joystick buttons, not motors. I do not know how to wire or program the relays so as to get a pwm output. I would appreciate any help. Thanks.
Replace xx with the pwm output youâll be using for the motor. In this case, pressing p1_sw_top will make the motor go full forward, p1_sw_trig will make it full reverse, and pressing both will do nothing.
hey,
I always wandered, when you press a button on a joystick (say the top button or trigger), does it ârememberâ it was pressed and hold a value of 1? I donât really understand this. otherwise, for the guy who posted this forum, he would have to be holding down the trigger, which seems like it would be problematic. do you know what I mean? how does that work.
When a button is pressed on a joystick, it is not remembered. If the motor was to be driven for some time and the user did not want to hold the button until the desired point, a flag would have to be used.
The flag would be set to one when the button is pressed which would enable code controlling relay ouputs or pwms. Once a desired outcome happens, the flag would have to be reset. The outcome could be a pot position being reached, an encoder count value, a set amount of time from either Kevinâs clock or a clock variable incremented every program cycle, or even the ORIGINAL BUTTON pressed on the joystick.