FTC Dual Joystick Problem

Hello FTC teams,

We are the Charging Champions, FTC team 8660 from SoCal. While programming our joysticks, we ran into some trouble trying to use the dual joystick function. We were able to connect to our Samantha wifi module and got it to work wirelessly with one joystick. However, if we ran a program using both joysticks, the program would only execute commands from one joystick.

We were wondering if someone could help us with our dilemma and provide a sample code that works with dual joysticks.

Here is a copy of our program:

#pragma config(Hubs, S1, HTMotor, HTServo, none, none)
#pragma config(Sensor, S1, , sensorI2CMuxController)
#pragma config(Motor, motorA, , tmotorNXT, openLoop)
#pragma config(Motor, motorB, , tmotorNXT, openLoop)
#pragma config(Motor, motorC, , tmotorNXT, openLoop)
#pragma config(Motor, mtr_S1_C1_1, leftMotor, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C1_2, rightMotor, tmotorTetrix, openLoop, reversed)
#pragma config(Servo, srvo_S1_C2_1, armLift, tServoStandard)
#pragma config(Servo, srvo_S1_C2_2, servo2, tServoNone)
#pragma config(Servo, srvo_S1_C2_3, servo3, tServoNone)
#pragma config(Servo, srvo_S1_C2_4, servo4, tServoNone)
#pragma config(Servo, srvo_S1_C2_5, servo5, tServoNone)
#pragma config(Servo, srvo_S1_C2_6, servo6, tServoNone)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//

#include “JoystickDriver.c” //Include joystickdriver.c

task main() //Task main.
{
while(true) //Forever loop.
{
getJoystickSettings(joystick); //Continually updates the joystick readings

	int servo1 = ServoValue[armLift]; //Sets the variable as the power of the servo motor

	if(abs(joystick.joy1_y1) > 10) //If the absolute value of the left joystick value is over 10, then the left motor will move
	{
		motor[leftMotor] = joystick.joy1_y1 * 75/127;
	}
	else if(abs(joystick.joy1_y2) > 10) //If the absolute value of the right joystick value is over 10, then the right motor will move
	{
		motor[rightMotor] = joystick.joy1_y2 * 75/127;
	}
	else
	{
		motor[leftMotor] = 0;
		motor[rightMotor] = 0;
	}
	if(abs(joystick.joy2_TopHat) == 0) //If the north arrow is pressed on the tophat, the servo motor will go up.
	{
		servo[armLift] = servo1--;
	}
	else if(abs(joystick.joy2_TopHat) == 2) //If the west arrow is pressed on the tophat, the nxt motor will move back.
	{
		motor[motorA] = -50;
	}
	else if(abs(joystick.joy2_TopHat) == 4) //If the south arrow is pressed on the tophat, the servo motor will go down.
	{
		servo[armLift] = servo1++;
	}
	else if(abs(joystick.joy2_TopHat) == 6) //If the west arrow is pressed on the tophat, the nxt motor will move back.
	{
		motor[motorA] = 50;
	}
	else //Otherwise, all motors will stop moving.
	{
		motor[motorA] = 0;
		servo[armLift] = servo1;
	}


	wait1Msec(5); //Wait for 5 milliseconds.
}

}

Please let us know if there is anything wrong with our program. All help is appreciated. Go FTC Teams!!!

Thanks,
Charging Champions
FTC Team 8660

Your code looks solid.

How are you trying to run your program?

If it’s through the robotC debugger or Joystick control windows, make sure you have the dual joystick option selected and that joystick 1 is selected on the left pane of the window and joystick 2 on the right pane.

If through the FCS(also applicable to RobotC), make sure that both joysticks are connected and configured within the software.

For future reference, it’s good to use the

 BBCode tabs when posting your code in a post.

while(true)
{
printf("Easier to read like this :slight_smile:
");
}