Skip to main content
corrected a mistake
Source Link
mactro
  • 953
  • 4
  • 16

There are two reasons reason for your problem:

  1. The main loop is executed very fast - you only check conditionals and assign some values to variables. Total execution time will be probably in order of milliseconds. That means that when you press the button for even as short as 0.1s the loop will execute thousands of times. I would advice on checking the button states only every 50-200 milliseconds.

  2. As already mentioned by SteveO, there is also an error in your logic. When variables a and c reach their maximum values, there is no way to reset them to their original state. I would do that like:

    if(buttonIsPressed()) {
      changeVariable();
    }
    if(variable > maxValue) {
      variable = maxValue;
    } 
    

Also, are you sure that you want arm and claw go to their base positions when you release buttons? That would be the effect of

else(vexRT[Btn7D] == 0 && vexRT[Btn7U] == 0);
{
  motor[Claw] = c;
}

There are two reasons reason for your problem:

  1. The main loop is executed very fast - you only check conditionals and assign some values to variables. Total execution time will be probably in order of milliseconds. That means that when you press the button for even as short as 0.1s the loop will execute thousands of times. I would advice on checking the button states only every 50-200 milliseconds.

  2. As already mentioned by SteveO, there is also an error in your logic. When variables a and c reach their maximum values, there is no way to reset them to their original state. I would do that like:

    if(buttonIsPressed()) {
      changeVariable();
    }
    if(variable > maxValue) {
      variable = maxValue;
    } 
    

Also, are you sure that you want arm and claw go to their base positions when you release buttons? That would be the effect of

else(vexRT[Btn7D] == 0 && vexRT[Btn7U] == 0);
{
  motor[Claw] = c;
}

There are two reasons reason for your problem:

  1. The main loop is executed very fast - you only check conditionals and assign some values to variables. Total execution time will be probably in order of milliseconds. That means that when you press the button for even as short as 0.1s the loop will execute thousands of times. I would advice on checking the button states only every 50-200 milliseconds.

  2. As already mentioned by SteveO, there is also an error in your logic. When variables a and c reach their maximum values, there is no way to reset them to their original state. I would do that like:

    if(buttonIsPressed()) {
      changeVariable();
    }
    if(variable > maxValue) {
      variable = maxValue;
    } 
    
Source Link
mactro
  • 953
  • 4
  • 16

There are two reasons reason for your problem:

  1. The main loop is executed very fast - you only check conditionals and assign some values to variables. Total execution time will be probably in order of milliseconds. That means that when you press the button for even as short as 0.1s the loop will execute thousands of times. I would advice on checking the button states only every 50-200 milliseconds.

  2. As already mentioned by SteveO, there is also an error in your logic. When variables a and c reach their maximum values, there is no way to reset them to their original state. I would do that like:

    if(buttonIsPressed()) {
      changeVariable();
    }
    if(variable > maxValue) {
      variable = maxValue;
    } 
    

Also, are you sure that you want arm and claw go to their base positions when you release buttons? That would be the effect of

else(vexRT[Btn7D] == 0 && vexRT[Btn7U] == 0);
{
  motor[Claw] = c;
}