View Single Post
  #1   Spotlight this post!  
Unread 28-02-2014, 22:08
2185Bilal's Avatar
2185Bilal 2185Bilal is offline
Driver, Ld. Programmer, Electrical
AKA: Bilal Majeed
FRC #2185 (Ramazoidz)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2011
Location: Toronto, Canada
Posts: 110
2185Bilal will become famous soon enough
Java wait Function

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
__________________
RAMAZOIDZ

2009 Toronto West Regional - Regional Winners
2009 Waterloo Regional - Regional Winners
Reply With Quote