The bot wont move... Is it the program or the motors? [ROBOTC]

I’m new to programming and I’m trying to program a robot right now and it doesn’t seem to be working. it says there are no errors in the programming, so what did I do wrong? Or is it the motors?

Here’s the code-

#pragma config(Motor,  port2,           FlipA,         tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port3,           WheelR,        tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port4,           WheelL,        tmotorVex393_MC29, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
	while(true)
	{
	motor[port2] = vexRT[Btn6U];	
	motor[port2] = vexRT[Btn6D];
	motor[port3] = vexRT[Ch2];	
	motor[port4] = vexRT[Ch3];

	if(vexRT[Ch3] == 1) //Forwards
	{
		motor[WheelL] = 127;
		motor[WheelR] = 127;
	}
	else 
	{
		motor[WheelL] = 0;
		motor[WheelR] = 0;
	}
	
	if(vexRT[Ch3] == 1) //Backwards
	{
		motor[WheelL] = -127;
		motor[WheelR] = -127;
	}
	else 
	{
		motor[WheelL] = 0;
		motor[WheelR] = 0;
	}
	if(vexRT[Ch1] == 1) //Left
	{
		motor[WheelL] = -127;
		motor[WheelR] = 127;
	}
	else if(vexRT[Ch1] ==1)
	{
		motor[WheelL] = 0;
		motor[WheelR] = 0;
	}
	
	if(vexRT[Ch1] == 1)//right
	{
		motor[WheelL] = 127;
		motor[WheelR] = -127;
	}
	else 
		motor[WheelL] = 0;
		motor[WheelR] = 0;
	}
	//Split between Wheels/Arm

	if(vexRT[Btn6U] == 1) //Up
	{
		motor[FlipA] = 127;
	}
	else 
	{
		motor[FlipA] = 0;
	}
}

check the braces {}, looks like you are missing at least one that would stop the FlipA motor from running.

1 Like

Thanks for the advice, but my main problem is actually moving the bot. It doesn’t seem to move forward or backwards ;-;.

you have multiple commands sending values to the same motors.
for example, this

motor[port4] = vexRT[Ch3];

and this

if(vexRT[Ch3] == 1) //Backwards
	{
		motor[WheelL] = -127;
		motor[WheelR] = -127;
	}
	else 
	{
		motor[WheelL] = 0;
		motor[WheelR] = 0;
	}
2 Likes

vexRT[Ch3] is joystick and will returns values from -127 to +127, not sure what the intent of this code was.

if(vexRT[Ch3] == 1)
2 Likes

Oh, so to fix it should I put a else if statement rather than a else because they are both true???

try something simpler to start with, perhaps this.

#pragma config(Motor,  port2,           FlipA,         tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port3,           WheelR,        tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port4,           WheelL,        tmotorVex393_MC29, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
	while(true)
	{
	motor[port2] = (vexRT[Btn6U] - vexRT[Btn6D]) * 50;	
	motor[port3] = vexRT[Ch2];	
	motor[port4] = vexRT[Ch3];
	wait1Msec(20);
    }
}
2 Likes

Alright, will do. Btw, what’s the purpose of subtracting and using different operations on the motors when declaring it?

I have tried this just now and it doesnt work :/.