Competition Switch

ok so I’m working with pros and when I use my competition switch when I plug it in it act fine but it doesn’t look at the code when I’m in driver mode it starts to run the autonomous code rather then using the aton code? any one know how to fix this?

What???

Post the code to start with

auto.c


#include "main.h"
	// Motor Port Values.
		int motorFrontRight = 4;
		int motorBackRight =  5;
		int motorFrontLeft = 3;
		int motorBackLeft = 2;

//Movement fuction.
	void move(int Y1, int X1, int Z1,int timeDelay){
		//Math Logic for each Motor.
			motorSet(motorFrontRight, -Y1 + Z1 - X1);
			motorSet(motorBackRight, Y1 + Z1 - X1);
			motorSet(motorFrontLeft, -Y1 + Z1 + X1);
			motorSet(motorBackLeft, Y1 + Z1 + X1);
			delay(timeDelay);
	}

void autonomous() {

	move(0,127,0,500);
	delay(20);
}



opcontrol.c


#include "main.h"

void operatorControl() {
	// Declare inital values.

		//Intialalize Movement Values.
		int Z1 = 0; //Declare piviot value.
		int Y1 = 0; //Declare Forward and Backward value. 
		int X1 = 0; //Declare Left and Right value.
		int threshold = 10; //Declare Deadzone Limit for controller joystick.		int wheelSpeedThreashold = 60; //Declare deadzone for luaching machine speed.


		// Initalize Debugging Values.
		int debugCtr = 0;

		// Initalize Motor Port Values.
        int backleft = 2;
        int frontleft = 3;
		int frontright = 4;
		int backright =  5;
		int shootingMechside1 = 8;
		int shootingMechside2 = 9;

        //Firing Motor Values
        int firingMotorPower = 0;


    while(1){/*Loop Forever*/
    	//Declare Joysticks.
        int leftStickLeft = joystickGetAnalog(1, 4);
        int leftStickUp = joystickGetAnalog(1, 3);
        int rightStickLeft = joystickGetAnalog(1, 1);
        int incFiringWheelSpeed = joystickGetDigital(1, 8, JOY_UP);
        int decFiringWheelSpeed = joystickGetDigital(1, 8, JOY_DOWN);




        if(abs(leftStickLeft) > threshold){ //Take the value of
            Y1 = leftStickLeft;
        }else{
            Y1 = 0;
        }

        if(abs(leftStickUp) > threshold){
            X1 = leftStickUp;
        }else{
            X1 = 0;
        }

        if(abs(rightStickLeft) > threshold){
            Z1 = rightStickLeft;
        }else{
            Z1 = 0;
        }

       /* if(firingMotorPower == 0 || incFiringWheelSpeed == 1){
        	firingMotorPower = 60;
        }*/

        if(incFiringWheelSpeed == 1){
        	firingMotorPower = firingMotorPower + 10;
        }

        if(decFiringWheelSpeed == 1){
        	firingMotorPower = firingMotorPower - 10;
        }

        //Firing Motor Power reset Functions
        if(firingMotorPower >= 130){
        	firingMotorPower = 120;
        }
        if(firingMotorPower <= 0){
        	firingMotorPower = 0;
        }


        //Math Logic for each Motor.
        motorSet(frontright, -Y1 + Z1 - X1);
        motorSet(backright, Y1 + Z1 - X1);
        motorSet(frontleft, -Y1 + Z1 + X1);
        motorSet(backleft, Y1 + Z1 + X1);

        // Finring Motor
        motorSet(shootingMechside1, firingMotorPower);
        motorSet(shootingMechside2, -firingMotorPower);


        delay(20);//Required for any working program at the end of the program in milliseconds?

        //Debugging Command.

       if( debugCtr++ == 5 ) //Display Values in PROS Terminal for debugging.
            {
            debugCtr = 0;
            // printf("Joystick Drive Values for: %d %d %d \r\n", Y1, X1, Z1, "Main Battery Level: %d \r\n", powerLevelMain(), "Firing Mechanism Motor Power: %d \r\n", firingMotorPower,"Square Selection: d% d% d% d% \r\n", digitalRead(1), digitalRead(2), digitalRead(3), digitalRead(4));
             printf("Firing Mechanism Motor Power: %d %d %d \r\n",joystickGetDigital(1 , 5, JOY_UP),firingMotorPower, powerLevelMain());
            //printf("Master Battery Power: %d",powerLevelMain(),"X1 = %d",X1 ,"Y1 = %d",Y1,"Z1 = %d",Z1);
            }

        }
}

OK and what is happening? Your robot runs the autonomous code when you put the competition switch in operator control mode?

Are you sure your competition switch is working (eg does it work with another robot/different code)?

it worked fine right before we went on summer break and I started working with the code lastnight and when I plugged it in It would go straight into aton mode will be able to test with a new bot Monday