View Single Post
  #4   Spotlight this post!  
Unread 12-03-2012, 23:22
Gigakaiser Gigakaiser is offline
Registered User
AKA: Brandon Hjelstrom
FRC #0987 (High Rollers)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Las Vegas
Posts: 67
Gigakaiser has a brilliant futureGigakaiser has a brilliant futureGigakaiser has a brilliant futureGigakaiser has a brilliant futureGigakaiser has a brilliant futureGigakaiser has a brilliant futureGigakaiser has a brilliant futureGigakaiser has a brilliant futureGigakaiser has a brilliant futureGigakaiser has a brilliant futureGigakaiser has a brilliant future
Lightbulb Re: Joystick Trigger and Button C++ Programming

In your operator control loop, you can write something like this:
Code:
if ((rightstick->GetRawButton(6) == 1) && (rightstick->GetRawButton(7) == 0)) //if button 6 is pressed and button 7 is released
{
     //In this check you will either "set" your victors
             victora->Set(.7f);
     //Or use a myrobot function
             myrobot.drive(//set parameters);
}
else if((rightstick->GetRawButton(7) == 1) && (rightstick->GetRawButton(6) == 0)) //if button 7 is pressed and button 6 is released
{
      // "set" your victors
             victora->Set(-.7f);
     //Or use a myrobot function
             myrobot.drive(//set parameters);
}
else // if nothing is pressed set all victors to zero or use a myrobot.drive with 0.0f
{
// turn off everything
             victora->Set(0.0f);
     //Or use a myrobot function
             myrobot.drive(//set parameters to 0.0f);

}
This will make sure your victors are being set to zero if both buttons are pressed or released. Test your robot on blocks before trying to drive!
__________________
FRC Team 987 - It's not enough
Reply With Quote