|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
problem while programming 2 bottuns in windriver
hey
we are trying to do 2 buttons for the same motor if button 1 pressed move forward .. else stop ... and then if button 2 pressed move backward else stop here is the code we are using but it doesn't work well : in the operatorcontrol we put this: Code:
if(leftjoystick->GetRawButton(1));
{
jaguar->Set(1.0);
}
else{
jaguar->Set(0.0);
}
if(leftjoystick->GetRawButton(2));
{
jaguar->Set(-1.0);
}
else{
jaguar->Set(0.0);
}
Code:
if(leftjoystick->GetRawButton(2));
{
jaguar->Set(-1.0);
}
else{
jaguar->Set(0.0);
}
please need answer Last edited by mahmosh : 12-02-2009 at 09:14. |
|
#2
|
||||
|
||||
|
Re: problem while programming 2 bottuns in windriver
Its a logic error, if you hold down button 1, then that will set the motor to 1, then since button 2 is not held down it will go to that else which will set it back to 0.
|
|
#3
|
|||||
|
|||||
|
Re: problem while programming 2 bottuns in windriver
Because you have two separate if...else statements, if the reverse button isn't held down, the output will be zero regardless of the forward button's state.
Also, this: Code:
if (condition); A quick rewrite yields this: Code:
if(leftjoystick->GetRawButton(1))
{
jaguar->Set(1.0);
}
else if (leftjoystick->GetRawButton(2)) {
jaguar->Set(-1.0);
} else {
jaguar->Set(0.0);
}
Alan Anderson let me know that I messed up. I misread your code snippet: I didn't realize that the reverse button would drive the motor in reverse... (crosses eyes) I really need some more sleep. Let me know if you have any more questions or problems. Jacob Last edited by JBotAlan : 12-02-2009 at 17:21. Reason: Oops. |
|
#4
|
||||
|
||||
|
Re: problem while programming 2 bottuns in windriver
thank you
it works well .... if i have any questions i will ask here |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| WindRiver Programming Template | kyungjin | C/C++ | 0 | 24-01-2009 16:42 |
| Potentiometer on cRIO, Programming in Windriver | sircedric4 | C/C++ | 3 | 20-01-2009 06:42 |
| WindRiver Programming | dnrobotics11 | C/C++ | 1 | 19-01-2009 20:13 |
| WindRiver Programming | dnrobotics11 | C/C++ | 4 | 19-01-2009 19:43 |
| Problem debugging code with WindRiver | LinuxMercedes | Programming | 3 | 07-01-2009 11:10 |