View Single Post
  #2   Spotlight this post!  
Unread 13-02-2015, 10:39
Ozuru's Avatar
Ozuru Ozuru is offline
It's always the programmer's fault.
no team
 
Join Date: May 2013
Rookie Year: 2010
Location: Earth
Posts: 268
Ozuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to behold
Re: Pneumatics, getting XBox input

Quote:
Originally Posted by SirGibbs View Post
Hey, I am from Team 5676 and we have some problems with the programming. I looked in some pneumatic threads, but I didn't found anything similar.

We want to work with pneumatics who get controlled by the Xbox controller.
When the XBox controller and all the buttons are defined, what is the best way to get the Xbox Input to let the pneumatics start working?

Code:
if(XboxController.button[0] == true)
		{
			pistonArm.set(DoubleSolenoid.Value.kForward);	
		
			System.out.println("'A' button is pressed: Piston moves forward");}
That is what we have, but it isn't working. It doesn't get the input. We would highly appreciate any input, ideas or solutions to make this better and solve it.

with best wishes

The Hornets
Your button getter method is kind of odd;

Code:
if(XboxController.getRawButton(0))
{
pistonArm.set(DoubleSolenoid.Value.kForward);
System.out.println("'A' button is pressed: Piston moves forward");}
Also, the == true part isn't essential -- if your expression will return true you don't have to add that.

For example:

Code:
// if 5 is bigger than 4 will evaluate to true
if(5 > 4) {
System.out.println("5 is bigger than 4!");
}

// less efficient way of doing the same thing posted above
if((5 > 4) == true) {
System.out.println("5 is bigger than 4!");
}
Your pneumatic control looks good, but here's a toggle function I have been using (that I know works):

Code:
public void toggleSolenoid1() {
    	if(solenoid1.get() == DoubleSolenoid.Value.kForward) {
    		solenoid1.set(DoubleSolenoid.Value.kReverse);
    	} else {
    		solenoid1.set(DoubleSolenoid.Value.kForward);
    	}
    }
Reply With Quote