View Single Post
  #2   Spotlight this post!  
Unread 20-02-2010, 17:15
ygd ygd is offline
Registered User
FRC #3341 (Manhattan Project)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2010
Location: San Diego
Posts: 26
ygd is an unknown quantity at this point
Re: solenoid problems

What's the point of this:

Code:
if (fluffy.getPressureSwitchValue()) {
fluffy.setRelayValue(edu.wpi.first.wpilibj. Relay.Value.kOff);
} else {
fluffy.setRelayValue(edu.wpi.first.wpilibj. Relay.Value.kOn);
}
Also, this was our code when we were using pneumatics for our kicker:

Code:
if (System.currentTimeMillis() - lastFired >= 2000) {
                if (j.getTrigger() && !fired) {
                    fire();
                    fired = true;
                    lastFired = System.currentTimeMillis();
                } else if (!j.getTrigger() && fired) {
                    fired = false;
                }
            }
            try {
                Thread.sleep(50);
            } catch (Exception e) {
                System.out.print(e.getMessage());
                e.printStackTrace();
            }
Where fire() launches the solenoids and fired is a boolean set to false and lastFired is a long set to 0. This code also makes sure you can only fire once every two seconds.
Reply With Quote