Go to Post 1. Build a robot. 2. Don’t let it get destroyed. - B-Bot [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 02-28-2014, 10:08 PM
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
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 08:14 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi