We're students trying to make a clawbot for a Science Seminar class. However, for some reason, whenever we try to move the arm or the claw in a certain way, it will lock up and only move that direction. Code attached. Please help.
#pragma config(Motor, port1, frWheel, tmotornormal, openLoop, reversed) //Setting up the motors
#pragma config(Motor, port5, brWheel, tmotornormal, openLoop, reversed)
#pragma config(Motor, port3, flWheel, tmotornormal, openLoop)
#pragma config(Motor, port4, blWheel, tmotornormal, openLoop)
#pragma config(Motor, port10, Arm, tmotornormal, openLoop)
#pragma config(Motor, port6, Claw, tmotornormal, openLoop)
task main()
{
int a = 0; //Arm integer
int c = 0; //Claw integer
while(true)
{
motor[frWheel] = vexRT(Ch2); //Wheels
motor[brWheel] = vexRT(Ch2);
motor[flWheel] = vexRT(Ch3);
motor[blWheel] = vexRT(Ch3);
if(a >= -30 && a <= 30) {
if(vexRT[Btn8D] == 1) //If arm down button pressed...
{
motor[Arm] = --a; //then arm will go down.
}
else if(vexRT[Btn8U] == 1)
{
motor[Arm] = ++a;
}
else(vexRT[Btn8U] == 0 && vexRT[Btn8D] == 0);
{
motor[Arm] = a;
}
}
else
{
}
if(c <= 30 && c >= -30)
{
if(vexRT[Btn7U] == 1) //If claw up button pressed...
{
motor[Claw] = ++c; //Claw will open.
}
else if(vexRT[Btn7D] == 1)
{
motor[Claw] = --c;
}
else(vexRT[Btn7D] == 0 && vexRT[Btn7U] == 0);
{
motor[Claw] = c;
}
}
else
{
}
}
}