![]() |
How do I Link a (group of) Joystick button(s) to a motor?
OK, I'm not new at the programming thing but I seem to be having one of those problems that I believe should have a simple solution. Long story short, our robot has a roller on the front. I want buttons 4, 3, and 5 on the Joystick attached to USB port 3 on the DS to control Reverse, Stop, and Forward respectively. I'm extending the IterativeRobot Class for this code. This is what I have so far:
Code:
// These lines are in the declarationBy the way, I've also tried using the Joystick::GetY() function to just output the Y axis on the Joystick directly to the Victor::Set() like this Code:
m_roller->Set(m_rollerStick->GetY());Thank you all for any help that you can provide for me. |
Re: How do I Link a (group of) Joystick button(s) to a motor?
I can't see anything wrong with the code you posted. I'm not sure that you are reading the stick, however.
Print out the status of "m_rollerStick->GetRawButton(X)" and make sure you are correctly reading the buttons. This will also indicate whether for some reason the block of code isn't getting run because of a conditional somewhere. Lastly, make sure you don't re-set "m_roller" later in the code. |
Re: How do I Link a (group of) Joystick button(s) to a motor?
I *think* I see the problem with your code. Basically, it won't hold the value the victor is set at.
It works this way: Say you push button 4. One cycle reads the button: if(m_rollerStick->GetRawButton(4)) m_rollerCondition = -1; and since it sees that button 4 is pushed, it sets the victor to -1. Then it cycles through again. But since you're not holding down the button, it won't keep the victor at -1. Instead, it will do your default action: default: m_roller->Set(0); break; which sets the victor back to 0. So what you should do is set up some code that reads a button state, sets a variable that stays at that value until it detects that a different button is pushed. I'll leave the implementation of that to the reader =] Let me know if that wasn't clear enough. I'm good at explaining things to myself; it's explaining things to others that's hard =] |
| All times are GMT -5. The time now is 02:39. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi