Any button other than joystick 2 making motor controlled by talon

If I use any buttons other than the joystick’s 2 buttons (named them left and right, 3 and 4 don’t work; 3 and 4 or 7 and 8 don’t work on the gamepad, named gamepad.)

Any idea why this would happen? One direction it doesn’t work at all, the other it works but goes off and on and generally moves very slowly. Also tried axis one of the gamepad.

Could you post your code?

Sorry, don’t know why I didn’t.

isthisatitle?
[spoiler]


/*----------------------------------------------------------------------------*/
/* 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.Compressor;
import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.Watchdog;
import edu.wpi.first.wpilibj.AnalogChannel;

import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

/**
 * 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 team4692robot extends SimpleRobot 
{
    RobotDrive drive=new RobotDrive(2, 1);
    Joystick left=new Joystick(1);
    Joystick right=new Joystick(2);
    Compressor airCompressor=new Compressor(1, 1);
    Solenoid launchopen=new Solenoid(1);
    Solenoid launchclose=new Solenoid(2);
    Joystick gamepad=new Joystick(3);
    Talon winch=new Talon(3);
    Talon ballpickup=new Talon(4);
    DigitalInput winchstopper=new DigitalInput(2);
    DigitalInput winchstarter=new DigitalInput(3);
    AnalogChannel distance=new AnalogChannel(1);
    Solenoid extendor1open=new Solenoid(3);
    Solenoid extendor1close=new Solenoid(4);
    Solenoid extendor2open=new Solenoid(5);
    Solenoid extendor2close=new Solenoid(6);
    DigitalInput pistonstopper=new DigitalInput(4);
    
    /**
     * This function is called once each time the robot enters autonomous mode.
     */
    public void autonomous() 
    {
        int autotimer=0; int pistontimer=0;
        
        airCompressor.start();
        
        while(true && isAutonomous() && isEnabled())
        {
            dashboard();
            
            if(distance.getAverageVoltage()/.0098>144 && autotimer==0)
            {
                drive.tankDrive(-.5, -.5);
            }
            else if(autotimer==0)
            {
                drive.tankDrive(0, 0);
                launchopen.set(true);
                launchclose.set(false);
                autotimer++;
            }
            else if(autotimer>0 && autotimer<200)
            {
                autotimer++;
            }
            else if(autotimer==200 && pistontimer==2000)
            {
                launchopen.set(false);
                launchclose.set(true);                
                autotimer++; pistontimer++;
            }
            if(pistontimer<1000)
            {
                extendor1open.set(true);
                extendor1close.set(false);
                pistontimer++;
            }
            else if(pistontimer<2000)
            {
                extendor2open.set(true);
                extendor2close.set(false);
                pistontimer++;
            }
            
            Timer.delay(.005);
        }
    }

    /**
     * This function is called once each time the robot enters operator control.
     */
    public void operatorControl() 
    {
        boolean winching=false; 
        int launchtimer=0; int reversewincher=0;
        
        airCompressor.start();
        
        while(true && isOperatorControl() && isEnabled())
        {
            double leftpow=left.getY(); double rightpow=right.getY();
            double powermod=.3;
            if(left.getTrigger())
            {
                powermod+=.2;
            }
            if(right.getTrigger())
            {
                powermod+=.5;
            }
            leftpow*=powermod; rightpow*=powermod;
            
            drive.tankDrive(leftpow, rightpow); 
            
            if(gamepad.getRawButton(1) && winching==false && winchstarter.get())
            {
                winching=true;
                reversewincher=0;
            }
            else if(winching==true)
            {
                winch.set(1);
                if(winchstopper.get())
                {
                    winching=false;
                    winch.set(-.5);
                    reversewincher=50;
                }
            }
            if(reversewincher>0)
            {
                winch.set(-.5);
                reversewincher--;
            }
            else if(winching==false)
            {
                winch.set(0);
            }
            
            if(gamepad.getRawButton(2) && launchtimer==0 && winching==false)
            {
                launchopen.set(true);
                launchclose.set(false);
                launchtimer=200;
            }
            if(launchtimer>1)
            {
                launchtimer--;
            }
            else
            {
                launchopen.set(false);
                launchclose.set(true);
            }
            if(launchtimer==1 && !gamepad.getRawButton(2))
            {
                launchtimer--;
            }
            
            if(gamepad.getRawButton(5))
            {
                extendor1open.set(false);
                extendor1close.set(true); 
            }
            if(gamepad.getRawAxis(3)>0)
            {
                extendor1open.set(true);
                extendor1close.set(false);                 
            }
            if(gamepad.getRawButton(6))
            {
                extendor2open.set(false);
                extendor2close.set(true); 
            }
            if(gamepad.getRawAxis(3)<0)
            {
                extendor2open.set(true);
                extendor2close.set(false);                 
            }
            
            if(left.getRawButton(2))
            {
                 ballpickup.set(-1);
            }
            if(right.getRawButton(2))
            {
                ballpickup.set(1);
            }
            
            if(!right.getRawButton(2) && !left.getRawButton(2))
            {
                 ballpickup.set(0);
            }
            
            dashboard();
            
            Timer.delay(.005);
        }
    }

            
            
    /**
     * This function is called once each time the robot enters test mode.
     */
    public void test() 
    {
    
    }
    
    public void robotInit()
    {
        drive.setSafetyEnabled(false);
        Watchdog.getInstance().kill();
    }
    
    public void dashboard()
    {
        SmartDashboard.putNumber("VOLTER", distance.getAverageVoltage()/.0098);
        SmartDashboard.putBoolean("SHOOTERFAR", distance.getAverageVoltage()/.0098>52);
        SmartDashboard.putBoolean("SHOOTERNEAR", distance.getAverageVoltage()/.0098<44);
    }
}

/*
double left=y; double right=y;
if(x>0)
{
    left+=x;
}
if(x<0)
{
    right+=x;
}
drive.tankDrive(left, right);
*/

[/spoiler]

This code is working, but we want to move the buttons to run it from joysticks to the gamepad:

   
            if(left.getRawButton(2))
            {
                 ballpickup.set(-1);
            }
            if(right.getRawButton(2))
            {
                ballpickup.set(1);
            }

Tried gamepad.getRawbutton(3), and gampepad.getRawButton(4), also tried left.getRawButton(3) and left.getRawButton(4), along with just setting ballpickup to one outside of that code, and setting it to gamepad.getRawAxis(1)… …none of that could get more than jerky movements, rapidly turning on and off.

UPDATE: Tried changing pwm to 5, it happens with any type of motor that I tested, it is only happening with ballpickup though, any statements of what I could be doing wrong, or information I have not provided would be nice.

EDIT: To make things stranger, setting it to a value in autonomous works perfectly fine.

EDIT: I facepalm myself:


            if(!right.getRawButton(2) && !left.getRawButton(2))
            {
                 ballpickup.set(0);
            }