Go to Post We try to do cool stuff (note: I didn't say it always works). - marshall [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

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 06-02-2016, 19:48
simon1636 simon1636 is offline
Registered User
FRC #4501
 
Join Date: Dec 2015
Location: California
Posts: 9
simon1636 is an unknown quantity at this point
More Solenoid Trouble

Hey guys! I am having trouble coding the solenoid. I want it to be so that whenever I push on the buttons on the top of the Attack 3 joystick, the solenoid opens up. The button labeled 3 on the Attack three opens the solenoid forward and the button 2 opens the solenoid backwards. However, my code does neither of this. In fact, I'm not sure if it's the code or not, but the air only come out of hole 2 of the solenoid. If you see anything that would be affecting the situation so that it doesn't work, let me know!

Code:
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved.                             */
/* Open Source Software - may be modified and shared by FRC teams. The code   */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project.                                                               */
/*----------------------------------------------------------------------------*/

package edu.wpi.first.wpilibj.templates;



import edu.wpi.first.wpilibj.DoubleSolenoid;
import edu.wpi.first.wpilibj.Jaguar;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.SimpleRobot;

/**
 * The VM is configured to automatically run this class, and to call the
 * functions corresponding to each mode, as described in the SimpleRobot
 * documentation. If you change the name of this class or the package after
 * creating this project, you must also update the manifest file in the resource
 * directory.
 */
public class RobotTemplate extends SimpleRobot {
    /**
     * This function is called once each time the robot enters autonomous mode.
     */
    
    Jaguar lTalon,rTalon;
    Joystick throttle;
    
    DoubleSolenoid exampleDouble;
    Joystick aimer;
    
    
    public void autonomous() {
        
    }

    /**
     * This function is called once each time the robot enters operator control.
     */
    
    public void robotInit(){
        lTalon=new Jaguar(3);
        rTalon=new Jaguar(4);
        throttle=new Joystick(1);
       
        exampleDouble=new DoubleSolenoid(1,2); 
    }
    public void operatorControl() {
    
        while(isOperatorControl() &&isEnabled()){
           lTalon.set(-throttle.getZ());
           rTalon.set(throttle.getZ());
        }
        
        if(aimer.getRawButton(3)){
            exampleDouble.set(DoubleSolenoid.Value.kForward);
        }
        
        else if(aimer.getRawButton(2)){
            exampleDouble.set(DoubleSolenoid.Value.kReverse);
        }
        
        else{
            exampleDouble.set(DoubleSolenoid.Value.kOff);
        }
    }
                 
            
}    
     
            
            
                
           


    
    
    /**
     * This function is called once each time the robot enters test mode.
     */
Reply With Quote
  #2   Spotlight this post!  
Unread 06-02-2016, 20:17
orangelight's Avatar
orangelight orangelight is offline
Registered User
AKA: Alex
FRC #0548 (Robostangs)
Team Role: Programmer
 
Join Date: Feb 2014
Rookie Year: 2014
Location: Northville
Posts: 166
orangelight is a splendid one to beholdorangelight is a splendid one to beholdorangelight is a splendid one to beholdorangelight is a splendid one to beholdorangelight is a splendid one to beholdorangelight is a splendid one to beholdorangelight is a splendid one to beholdorangelight is a splendid one to behold
Re: More Solenoid Trouble

All the code that should run during teleop should be placed in the while loop.
__________________


Reply With Quote
  #3   Spotlight this post!  
Unread 07-02-2016, 17:07
simon1636 simon1636 is offline
Registered User
FRC #4501
 
Join Date: Dec 2015
Location: California
Posts: 9
simon1636 is an unknown quantity at this point
Re: More Solenoid Trouble

So I changed it so that all the Solenoid code is in the while loop, but it still isn't working! Do any of you guys see anything else wrong with the code?

Code:
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved.                             */
/* Open Source Software - may be modified and shared by FRC teams. The code   */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project.                                                               */
/*----------------------------------------------------------------------------*/

package edu.wpi.first.wpilibj.templates;



import edu.wpi.first.wpilibj.DoubleSolenoid;
import edu.wpi.first.wpilibj.Jaguar;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.SimpleRobot;

/**
 * The VM is configured to automatically run this class, and to call the
 * functions corresponding to each mode, as described in the SimpleRobot
 * documentation. If you change the name of this class or the package after
 * creating this project, you must also update the manifest file in the resource
 * directory.
 */
public class RobotTemplate extends SimpleRobot {
    /**
     * This function is called once each time the robot enters autonomous mode.
     */
    
    Jaguar lTalon,rTalon;
    Joystick throttle;
    
    DoubleSolenoid exampleDouble;
    Joystick aimer;
    
    
    public void autonomous() {
        
    }

    /**
     * This function is called once each time the robot enters operator control.
     */
    
    public void robotInit(){
        lTalon=new Jaguar(3);
        rTalon=new Jaguar(4);
        throttle=new Joystick(1);
       
        exampleDouble=new DoubleSolenoid(1,2); 
    }
    public void operatorControl() {
    
        while(isOperatorControl() &&isEnabled()){
           lTalon.set(-throttle.getZ());
           rTalon.set(throttle.getZ());
        
        
        if(aimer.getY()>0){
            exampleDouble.set(DoubleSolenoid.Value.kForward);
        }
        
        else if(aimer.getY()<0){
            exampleDouble.set(DoubleSolenoid.Value.kReverse);
        }
        
        else{
            exampleDouble.set(DoubleSolenoid.Value.kOff);
        }
        }  
    }
                 
            
}    
     
            
            
                
           


    
    
    /**
     * This function is called once each time the robot enters test mode.
     */
Reply With Quote
Reply


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 22:37.

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