What we want to do is to have our solenoids to open and then after like 0.5 seconds have it close automatically.
This is our code so far:
Code:
if (j_shooting.getRawButton(2)){ //FORWARD - BUTTON A
flag = 1;
}else if (j_shooting.getRawButton(1)){ //BACKWARD - BUTTON X
cyl_shoot.set(DoubleSolenoid.Value.kForward);
}else {
cyl_shoot.set(DoubleSolenoid.Value.kOff);
}
if (flag == 1){
cyl_shoot.set(DoubleSolenoid.Value.kReverse);
try {
Thread.sleep(500);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
cyl_shoot.set(DoubleSolenoid.Value.kForward);
flag = 0;
}
**ignore the indentation, and the kForward and kBackwards, its switched
So my question is, is the code i have right now good and if not what other options is there to have the pistons open, pause for 0.5 seconds, and then close.
thanks