![]() |
Joystick Trigger and Button C++ Programming
Hello. I am on a Rookie team and I am a Rookie programmer. I have no idea how to program the buttons on the joystick. I just need help programming the buttons for our robot's shooter motor and intake motor. Any help would be appreciated.
Thank you! Code:
/** |
Re: Joystick Trigger and Button C++ Programming
Can you be a little more detailed about what you want? What exactly do you want the motors to do when you press a button, and when you release the button? Which buttons do you want to use? Be as specific as you can.
|
Re: Joystick Trigger and Button C++ Programming
I want the motors to run when I press it, and stop when I release it. I also wanted to use number 6 and 7 buttons.
|
Re: Joystick Trigger and Button C++ Programming
In your operator control loop, you can write something like this:
Code:
if ((rightstick->GetRawButton(6) == 1) && (rightstick->GetRawButton(7) == 0)) //if button 6 is pressed and button 7 is released |
Re: Joystick Trigger and Button C++ Programming
Thank you!
Would this make it so that button 6 controls one motor, and button 7 controls the other one? |
Re: Joystick Trigger and Button C++ Programming
Actually, that would reverse your victors per button (for an intake?) - pressing button 6 would set your victor to +.7, whilie pressing button 7 would set your victor to -.7.
If you want each button to turn on a different victor, write this: Code:
//pressing 6 will turn on intake, releasing 6 will stop intake |
Re: Joystick Trigger and Button C++ Programming
Brandon posted example code that uses victora as a placeholder. You'll need to define the other two motors you want to control, initialize them appropriately, and set whichever one you want to run in the proper place in the code.
Are you actually using Victor speed controllers? As a rookie team, I'd expect you to have Jaguars. They have different responses to PWM signals, and you won't get the best results unless the programming matches the hardware. |
Re: Joystick Trigger and Button C++ Programming
Yes, we are using victors.
Also, I'm not sure where to paste the code. I understand it should be in the operator control loop, but I'm unsure where exactly. |
Re: Joystick Trigger and Button C++ Programming
Paste the code in the "while(IsOperator)" loop. Any code pasted in that while loop will run for the duration of the match.
|
Re: Joystick Trigger and Button C++ Programming
Like this?
Code:
void OperatorControl(void)Code:
void OperatorControl(void) |
Re: Joystick Trigger and Button C++ Programming
Your first example is correct. Just check that you are using the correct victors.
- You should move the Wait(0.005); directly below Code:
else if(rightstick->GetRawButton(6) == 0) |
| All times are GMT -5. The time now is 16:56. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi