View Single Post
  #3   Spotlight this post!  
Unread 12-02-2009, 09:42
JBotAlan's Avatar
JBotAlan JBotAlan is offline
Forever chasing the 'bot around
AKA: Jacob Rau
FRC #5263
Team Role: Mentor
 
Join Date: Sep 2004
Rookie Year: 2004
Location: Riverview, MI
Posts: 723
JBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond repute
Send a message via AIM to JBotAlan Send a message via Yahoo to JBotAlan
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);
has no code to execute because of that trailing semicolon. An "if" will execute the statement immediately after it up until a semicolon, or if you put the code inside {curly braces}, it will execute everything in the first set of braces. If statements don't need any additional semicolons.

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);
}
That will work.

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
__________________
Aren't signatures a bit outdated?

Last edited by JBotAlan : 12-02-2009 at 17:21. Reason: Oops.
Reply With Quote