Motor Controllers

I would like to know how to set a motor controller to a joystick. This year we are using tank drive with four motors. When I push on a joystick the front two motors move and one is moving backwards. I really need help.
(Ignore the Mecanum 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.                                                               */
/* Written by 2T's                                                            */
/* PizzaLovers007 and Lordninjaassassin                                       */
/* (c) 2014                                                                   */
package edu.wpi.first.wpilibj.templates;

import edu.wpi.first.wpilibj.DriverStationLCD;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SpeedController;
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.image.BinaryImage;
import edu.wpi.first.wpilibj.image.ColorImage;
import edu.wpi.first.wpilibj.image.CriteriaCollection;
import edu.wpi.first.wpilibj.image.NIVision;
import edu.wpi.first.wpilibj.image.NIVisionException;
import edu.wpi.first.wpilibj.image.ParticleAnalysisReport;

public class Robot2014 extends IterativeRobot {

    private Joystick leftStick;
    private Joystick rightStick;
    private RobotDrive drive;
    private AxisCamera camera;
    private DriverStationLCD lcd = DriverStationLCD.getInstance();
    private SpeedController m_FrontLeft;
    private SpeedController m_FrontRight;
    private SpeedController m_BackLeft;
    private SpeedController m_BackRight;
    private CriteriaCollection cc;

    public void robotInit() {

        camera = AxisCamera.getInstance();
        lcd.println(DriverStationLCD.Line.kUser2, 1, "Enabled!");
        cc = new CriteriaCollection();
        cc.addCriteria(NIVision.MeasurementType.IMAQ_MT_AREA, 500, 65535, false);

    public void joystickInit() {
        leftStick = new Joystick(1);
        rightStick = new Joystick(2);

    public void robotDriveInit() {
        drive = new RobotDrive(m_FrontLeft, m_BackLeft, m_FrontRight, m_BackRight);

    public void talonInit() {

        m_FrontLeft = new Talon(1);
        m_FrontRight = new Talon(2);
        m_BackLeft = new Talon(3);
        m_BackRight = new Talon(4);


    public void disabledContinuous() {

    public void disabledInit() {
        lcd.println(DriverStationLCD.Line.kUser2, 1, "Disabled!");

    public void disabledPeriodic() {

    public void autonomousInit() {
        lcd.println(DriverStationLCD.Line.kUser2, 1, "Autonomous!");

        boolean hotGoalLeft = false;

        //Calculate hot goal (may suck)
        try {
            ColorImage image = camera.getImage();
            BinaryImage thresholdImage = image.thresholdRGB(0, 45, 25, 255, 0, 47);
            BinaryImage convexHullImage = thresholdImage.convexHull(false);
            BinaryImage filteredImage = convexHullImage.particleFilter(cc);
            ParticleAnalysisReport] reports = filteredImage.getOrderedParticleAnalysisReports();
            for (int i = 0; i < reports.length; i++) {
                ParticleAnalysisReport rep = reports*;
                if (rep.boundingRectWidth > rep.boundingRectHeight && rep.boundingRectHeight > 5) {
                    hotGoalLeft = (rep.center_mass_x_normalized < 0) ? true : false;

        } catch (NIVisionException ex) {
        } catch (AxisCameraException ex) {

        //Turn towards hot goal
        if (hotGoalLeft) {
            drive.mecanumDrive_Polar(0, 0, -1);
        } else {
            drive.mecanumDrive_Polar(0, 0, 1);

        //TODO shoot or something...

        //Turn back forward
        if (hotGoalLeft) {
            drive.mecanumDrive_Polar(0, 0, 1);
        } else {
            drive.mecanumDrive_Polar(0, 0, -1);

        //Move forward
        drive.mecanumDrive_Cartesian(0, 0.5, 0, 0);

        //Stop and wait
        drive.mecanumDrive_Cartesian(0, 0, 0, 0);

    public void autonomousPeriodic() {

    public void teleopInit() {
        lcd.println(DriverStationLCD.Line.kUser2, 1, "Teleop!");

    public void teleopPeriodic() {

        // drive.mecanumDrive_Polar(leftStick.getMagnitude(), leftStick.getDirectionDegrees(), rightStick.getX());
        // drive.mecanumDrive_Cartesian(leftStick.getAxis(Joystick.AxisType.kX),
        // leftStick.getAxis(Joystick.AxisType.kY),
        // rightStick.getAxis(Joystick.AxisType.kX), 0);
        drive.tankDrive(leftStick.getY(), rightStick.getY());
        //   drive.mecanumDrive_Polar(leftStick.getY(), leftStick.getX(), rightStick.getTwist());
        //TODO add ball manipulation device operations

At a quick glance, the code looks fine. Check to make sure that the 4 talons are plugged into the correct ports and are plugged in correctly. Also check in the driver station that the joysticks are in the first 2 slots in the setup tab.

Additional information, when you enable are the lights on all 4 Talons going solid to show that they have communication?
When you move the joysticks, are all 4 Talons flashing red or green to show they are trying to move?

I checked everything. The talons are a solid yellow when not used and the joysticks are in ports one and two. When I push the joysticks forward the talons are a solid red and backwards a solid green. Is it supposed to be green forward?

One side is going to give you red and one is going to give you green when you push forward because your motors are facing opposite directions so the motor controllers need to spin the one side backwards.

All 4 are red when you push it forward?

I fixed it by pulling out the pwm cables and plugging them in until they all moved correctly.
Thank you for your help.

What are the back 2 doing? Green? If this is the case it seems like maybe your The ports that your Talons are plugged into might be swapped. According to your code you should have these Talons plugged into the following ports:
Front Left - 1
Front Right - 2
Rear Left - 3
Rear Right - 4

No problem, glad it was that easy.