I need help with my code does someone think that they can help me correct this code for my claw bot for school

#pragma config(Motor, port1, leftMotor, tmotorVex393, openLoop, reversed)
#pragma config(Motor, port6, clawMotor, tmotorVex269, openLoop, reversed)
#pragma config(Motor, port7, armMotor, tmotorVex393, openLoop, reversed)
#pragma config(Motor, port10, rightMotor, tmotorVex393, openLoop)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//

/----------------------------------------------------------------------------------------------------
|* - Clawbot Single Joystick Control - |
|
ROBOTC on VEX 2.0 Cortex |
|
|
|
This program uses a single joystick, either right or left to drive the robot. Use notes below |
|
to reconfigure which joystick is used. The joystick buttons are used to raise and lower the arm. |
|
The joystick buttons are used to open and close the claw. |
|
|
|
ROBOT CONFIGURATION |
|
NOTES: |
|
1) Ch1 is the X axis and Ch2 is the Y axis for the RIGHT joystick. |
|
2) Ch3 is the Y axis and Ch4 is the X axis for the LEFT joystick. |
|
3) Button 5U and 5L are on the front left side of the joystick. |
|
3) Button 6U and 6L are on the front right side of the joystick. |
|
|
|
MOTORS & SENSORS: |
|
[I/O Port] [Name] [Type] [Description] |
|
Motor - Port 2 rightMotor VEX 393 Motor Right drive motor |
|
Motor - Port 6 clawMotor VEX 393 Motor w/ Motor Controler 29 Claw motor |
|
Motor - Port 7 armMotor VEX 393 Motor w/ Motor Controler 29 Arm motor |
|
Motor - Port 10 leftMotor VEX 393 Motor Left drive motor |
*----------------------------------------------------------------------------------------------------
/

//+++++++++++++++++++++++++++++++++++++++++++++| MAIN |+++++++++++++++++++++++++++++++++++++++++++++++
task main ()
{

while(1 == 1)
{
	motor[leftMotor]  = (vexRT[Ch2] + vexRT[Ch1])/2;  // (y + x)/2
	motor[rightMotor] = (vexRT[Ch2] - vexRT[Ch1])/2;  // (y - x)/2

	// Raise, lower or do not move arm
	if(vexRT[Btn5U] == 1)       	//If button 5U is pressed...
	{
		motor[armMotor] = 127;    	//...raise the arm.
	}
	else if(vexRT[Btn5D] == 1)  	//Else, if button 5D is pressed...
	{
		motor[armMotor] = -127;   	//...lower the arm.
	}
	else                      		//Else (neither button is pressed)...
	{
		motor[armMotor] = 0;      	//...stop the arm.
	}

	// Open, close or do not more claw
	if(vexRT[Btn6U] == 1)       	//If Button 6U is pressed...
	{
		motor[clawMotor] = 127;  		//...close the gripper.
	}
	else if(vexRT[Btn6D] == 1)  	//Else, if button 6D is pressed...
	{
		motor[clawMotor] = -127; 		//...open the gripper.
	}
	else                      		//Else (neither button is pressed)...
	{
		motor[clawMotor] = 0;    		//...stop the gripper.
	}
}

}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Can you please say what is going wrong with this code? Does it note compile, does some function of the robot not work.

At a glance, you have the motor on port 6 configured as a 269 instead of a 393

1 Like

well i tried switching the motors and it still didn’t work and what’s going on is that the right side of the robot is not working and the claw isn’t working either

I agree with @Nerdom, the only thing that stands out in the code is that you have the claw motor configured as a 269 (but it may actually be a 269). Are you sure it’s a code issue? Could it simply be a shaft out of the motor? Motor pin broken/not plugged in? You might want to make sure it isn’t something like that.

1 Like

ok thank you i think that i might have to replace those two motors

Cortex has two internal PTCs that protect from motors drawing too much current.

One protects ports 1-5 and another protects ports 6-10.

If something like a shorted motor wire keeps tripping one of the PTCs, then it could explain entire side of the robot not having the power at the same time.

Check your motor and controller wires for any damage, try to replace or connect one motor at a time to eliminate if any of them is damaged.

In the worst case one side of the Cortex could have a blown PTC. You may need to move all motors to the other side, but don’t do it until you are sure the motor has no problem, or the other side could get damaged too.

1 Like