sections of code wont run

I couldn’t respond to my last conversation, however i am still having issues regarding my code, which will not run the lift portion on my robot once it is downloaded, I was wondering if anyone knew whats up, and if it might be an issue with my code of with the remote it self
I have the code running to move my lift using button 6, yet when ever I download the code to the robot, nothing will move using any on the buttons (other than the joysticks which run my chassis). I have tried all of the following in order to try and troubleshoot, yet nothing seems to work:
-changing what button
-downloading new firmware
-replacing motors
-changing format of the code (which was recommended in the last forum post i had)
-rewriting the code

I am a new coder so it might just be some simple mistake but I’m not sure!
below is an attachment of what this section of my code looks like

pasted_image.png

I’m guessing that you only have four motors on your lift, in the code you are setting eight motors. You need to have it setting just four motors going all in the same direction for each “if” loop. Also just have four motors in the motor and sensor setup, not one for each direction.

I can write the code for it if you want me too, just to give an example.

A, are the if statements contained within a while loop? They need to be. B, if you have already done that, try deleting the else on line 63. C, if that doesn’t fix it, try changing the else on line 77 to (idk if this is the correct function) elif((vexRT[Btn6U] == 0) && (vexRT[Btn6D] == 0))

Is it in a while(true)?

Please post all your code so the community can better help you.

Either paste it in the forum in a

 block or on a service like [Pastebin](pastebin.com) or [Github](github.com).

Here is the copy of my code, right now we have out lift with 8 motors but I’m working on a solution with one of my builders to be able to bring it down to 4 motors

#pragma config(Motor, port1, rightliftindown, tmotorVex393_HBridge, openLoop)
#pragma config(Motor, port2, rightdrive, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port3, rightliftinup, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port4, leftliftoutup, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port5, leftliftinup, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port6, leftliftindown, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port7, leftliftoutdown, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port8, rightliftoutup, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port9, leftdrive, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port10, rightliftoutdown, tmotorVex393_HBridge, openLoop)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//

/----------------------------------------------------------------------------------------------------
|* - Dual Joystick Control with 4 Motors - |
|
ROBOTC on VEX 2.0 Cortex |
|
|
|
This program uses both the Left and the Right joysticks to run the robot using “tank control”. |
|
|
|
ROBOT CONFIGURATION |
|
NOTES: |
|
1) Reversing both right-side motors (ports 2 and 3) in the “Motors and Sensors Setup” is |
|
needed with the “VEX Tumbler” model, but may not be needed for all robot configurations. |
|
2) Ch1 is the X axis and Ch2 is the Y axis for the RIGHT joystick. |
|
3) Ch3 is the Y axis and Ch4 is the X axis for the LEFT joystick. |
*----------------------------------------------------------------------------------------------------
/

//+++++++++++++++++++++++++++++++++++++++++++++| MAIN |+++++++++++++++++++++++++++++++++++++++++++++++

//////////////////////////////////////////////////////////////////////////////////////////
// User control task //
// this is a task to control the robot during the user control phase of the competition //
// //
//////////////////////////////////////////////////////////////////////////////////////////

task main()
{
while(1 == 1)
{
//Right side of the robot is controlled by the right joystick, Y-axis
motor[rightdrive] = vexRT[Ch2];
//Left side of the robot is controlled by the left joystick, Y-axis
motor[leftdrive] = vexRT[Ch3];
//moving the arm up (all together)
}

	if(vexRT[Btn6U] == 1)
		//moving the arm up (all together)
		{
	motor[leftliftoutup] = 127;
	motor[leftliftoutdown] = 127;
	motor[leftliftinup] = -127;  //move up
	motor[leftliftindown] = -127;
	motor[rightliftoutup] = -127;
motor[rightliftoutdown] = -127;
motor[rightliftinup] = 127;
motor[rightliftindown] = 127;
		}
	else

	if(vexRT[Btn6D] == 1)
		//moving the arm down (all together)
		{
	motor[leftliftoutup] = -127;
	motor[leftliftoutdown] = -127;
	motor[leftliftinup] = 127;  //move down
	motor[leftliftindown] = 127;
	motor[rightliftoutup] = 127;
motor[rightliftoutdown] = 127;
motor[rightliftinup] = -127;
motor[rightliftindown] = -127;
		}
	else
	{
	motor[leftliftoutup] = 0;
	motor[leftliftoutdown] = 0;
	motor[leftliftinup] = 0;  //not moving
	motor[leftliftindown] = 0;
	motor[rightliftoutup] = 0;
motor[rightliftoutdown] = 0;
motor[rightliftinup] = 0;
motor[rightliftindown] = 0;

	}



}

]

The immediate problem I see is that you close your while loop before your if statements that control the motors. The program is stuck looping on just your joystick controls. All you have to do to fix this is move the if statements into the same while loops as the drive motor controls.

So do I create an extra while statement before the if statements that control the motors, or do i just extend the one that is already there?

Thank you all, i got it to work :slight_smile: