Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   CAN ANYONE HELP ME PLEASE?? (http://www.chiefdelphi.com/forums/showthread.php?t=85296)

krudeboy51 16-04-2010 17:21

CAN ANYONE HELP ME PLEASE??
 
I wrote a this code for our arm release:

Quote:

if ( (ThirdStick->GetRawButton(6) ) )

{
ArmRelease -> Set(1.0);
}
else
{
ArmRelease->Set(0.0);
}


if ( (ThirdStick->GetRawButton(7) ) )
{
ArmRelease ->Set(-1.0);
}
else
{
ArmRelease->Set(0.0);
}
this means when i press buton 6 on the joystick the motor is supposed to go forward, and when i press button 7 on the joystick the motor is supposed o go backwards. button 6 work, the motor goes forward, but when i press button 7 it doesnt move. i even tried:

Quote:

if ( (ThirdStick->GetRawButton(6) ) )

{
ArmRelease -> Set(1.0);

while (ThirdStick->GetRawButton(7)
{
ArmRelease->Set(-1.0);
}
}
else
{
ArmRelease->Set(0.0);
}
but it still dont work! :confused:

Radical Pi 16-04-2010 17:30

Re: CAN ANYONE HELP ME PLEASE??
 
Huge flaw in your code. Here's a hypothetical situation based on the first one shown:

Button is 6 is pressed. The motor is set to 1.0. However, almost immediately after that, button 7 is checked and most likely set to 0.0.

Here's what I think you want:

Code:

if (ThirdStick->GetRawButton(6)) {
    ArmRelease->Set(1.0);
} else if (ThirdStick->GetRawButton(7)) {
    ArmRelease->Set(-1.0);
} else {
    ArmRelease->Set(0.0);
}

Also, I assume you mean if instead of while in that second code block. That version would only activate button 7 mode if button 6 was pressed

krudeboy51 16-04-2010 17:38

Re: CAN ANYONE HELP ME PLEASE??
 
Quote:

Originally Posted by Radical Pi (Post 954270)
Huge flaw in your code. Here's a hypothetical situation based on the first one shown:

Button is 6 is pressed. The motor is set to 1.0. However, almost immediately after that, button 7 is checked and most likely set to 0.0.

Here's what I think you want:

Code:

if (ThirdStick->GetRawButton(6)) {
    ArmRelease->Set(1.0);
} else if (ThirdStick->GetRawButton(7)) {
    ArmRelease->Set(-1.0);
} else {
    ArmRelease->Set(0.0);
}

Also, I assume you mean if instead of while in that second code block. That version would only activate button 7 mode if button 6 was pressed

THANKS ALOT MAN!!!!, I FORGOT ALL ABOUT ELSE IF STATEMENTS


All times are GMT -5. The time now is 13:50.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi