View Single Post
  #1   Spotlight this post!  
Unread 10-02-2015, 08:48
nguobadia nguobadia is offline
Registered User
FRC #5608
 
Join Date: Feb 2015
Location: United States
Posts: 1
nguobadia is an unknown quantity at this point
Toggling Buttons

Hi from team 5608! So I'm trying to figure out how to toggle the buttons on our joysticks so that we can turn on and off our solenoids. I keep trying to do it, but they keep conflicting with each other so the pistons either twitch or nothing happens.
So just some background: we have 4 solenoids and 2 joysticks, one joystick for every two solenoids, however Button 3 (raw button) on both joysticks are used to activate their respective solenoids.
Here's our code (I'll give you just one of them since the code would be almost identical for the other one):

/**Toggles the right joystick button 3.*/
public void rightToggle(){

if (right.getRawButton(3)){
if(!isPressedPiston1){
switchSol1 = !switchSol1;

}else {
isPressedPiston1 = !isPressedPiston1;

}
if (switchSol1){
sol1.set(true);
sol2.set(true);

}else {
sol1.set(false);
sol2.set(false);

}

}

}
Reply With Quote