View Single Post
  #1   Spotlight this post!  
Unread 20-02-2010, 16:36
Twisted eric's Avatar
Twisted eric Twisted eric is offline
Registered User
FRC #0581
 
Join Date: Jan 2010
Location: San Jose
Posts: 54
Twisted eric is an unknown quantity at this point
solenoid problems

I need help with Programming the solenoid to a the trigger button on our controller it will be on the kicker joystick.

Code:
package edu.wpi.first.wpilibj.templates;

import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Watchdog;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.Jaguar;


public class Demonized extends SimpleRobot {

    private static final long TIME_DELAY = 1000; // in milliseconds
    RobotDrive drive = new RobotDrive(1, 2);
    Joystick leftStick = new Joystick(1);
    Joystick rightStick = new Joystick(2);
    Joystick kicker = new Joystick(3);
    Watchdog fenrir = Watchdog.getInstance();
    Compressor fluffy = new Compressor(1, 1);
    Joystick leftstick = new Joystick(1);
    Joystick rightstick = new Joystick(2);
    Jaguar spot = new Jaguar(4);
    Joystick pup = new Joystick(4);
   
    void setUpRobot() {
        fluffy.start();
        fenrir.feed();
    }



    public void autonomous() {
        setUpRobot();
            while (true && isAutonomous() && isEnabled()) {
                for (int i = 0; i < 4; i++) {
                    fenrir.feed();
                    drive.drive(0.5, 0.0);  // drive 50% fwd 0% turn
                    fenrir.feed();
                    drive.drive(0.0, 0.5);  // drive 0% fwd 50% turn
                    fenrir.feed();
                    drive.drive(0.0, -0.5); // drive 0% fwd -50% turn
                }
            }
            drive.drive(0.0, 0.0); // drive 0% fwd, 0% turn   
    }
    public void operatorControl() {
        setUpRobot();
        while (true && isOperatorControl() && isEnabled()) // loop until change
        {
            drive.tankDrive(leftStick, rightStick);
            Timer.delay(0.005);
            fenrir.feed();
            
           // New compressor code...
if (fluffy.getPressureSwitchValue()) {
fluffy.setRelayValue(edu.wpi.first.wpilibj. Relay.Value.kOff);
} else {
fluffy.setRelayValue(edu.wpi.first.wpilibj. Relay.Value.kOn);
}


            
            
        }
    //And don't forget to turn the compressor off when exiting your operatorControl loop...

fluffy.setRelayValue(edu.wpi.first.wpilibj. Relay.Value.kOff); 
}
}

help will be much appreciated.
Reply With Quote