View Single Post
  #3   Spotlight this post!  
Unread 23-01-2009, 20:30
LinuxMercedes LinuxMercedes is offline
Real men use Macs
FRC #1444 (Lightning Lancers)
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: St. Louis, MO
Posts: 22
LinuxMercedes is an unknown quantity at this point
Re: Programming Joystick Buttons to toggle a motor on and off

One bug in your code, byteit101

Quote:
Originally Posted by byteit101 View Post
Joystick stick3(3);//obviously
Jaguar jag1(3);//PWM port 3
bool btn3state=false;


if (stick3.GetRawButton(3))
{
if (!btn3state) //if the button has not been depressed
{
jag3.Set(0.5);
btn3state=true; //the button has been depressed
}
else
{
jag3.Set(0.0);
btn3state=false; //the button was clicked again
}
}
Otherwise, you'd click the button first to set the jag to 0, then the second click would set it to 0.5. Unless I missed something.
__________________
Reply With Quote