I cleaned your code up a bit. One issue you had was that you were creating new references to your pistons every ~20ms which is a bad thing to do. You were also sharing the same reference for ever single piston, also a bad thing to do. You can see that I moved the created 2 more pistons and created their references in robotInit().
Code:
package org.usfirst.frc.team5676.robot;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.DoubleSolenoid;
import edu.wpi.first.wpilibj.RobotDrive;
public class Robot extends IterativeRobot {
RobotDrive myRobot;
Joystick stick;
DoubleSolenoid piston1;
DoubleSolenoid piston2;
DoubleSolenoid piston3;
public void robotInit() {
myRobot = new RobotDrive (0, 1, 2, 3);
stick = new Joystick(0);
piston1 = new DoubleSolenoid(0, 1)
piston2 = new DoubleSolenoid(2, 3);
piston3 = new DoubleSolenoid(4, 5);
}
public void autonomousPeriodic() {
}
public void teleopPeriodic() {
myRobot.arcadeDrive(stick);
if (stick.getRawButton(5)) {
piston1.set(DoubleSolenoid.Value.kForward);
ystem.out.println("'A' button is pressed: Piston moves forward");
} else if (stick.getRawButton(6)) {
piston1.set(DoubleSolenoid.Value.kReverse);
System.out.println("'B' button is pressed: Piston moves backward");
} else {
piston1.set(DoubleSolenoid.Value.kOff);
}
if (stick.getRawButton(3)) {
Ppiston2.set(DoubleSolenoid.Value.kForward);
System.out.println("'A' button is pressed: Piston moves forward");
} else if (stick.getRawButton(4)) m{
piston2.set(DoubleSolenoid.Value.kReverse);
System.out.println("'B' button is pressed: Piston moves backward");
} else {
piston2.set(DoubleSolenoid.Value.kOff);
}
if (stick.getRawButton(1)) {
piston3.set(DoubleSolenoid.Value.kForward);
System.out.println("'A' button is pressed: Piston moves forward");
} else if (stick.getRawButton(2)) {
piston3.set(DoubleSolenoid.Value.kReverse);
System.out.println("'B' button is pressed: Piston moves backward");
} else {
piston3.set(DoubleSolenoid.Value.kOff);
}
}
/**
* This function is called periodically during test mode
*/
public void testPeriodic() {
}
}