I am one of the programmers on my team, and somebody else on the team made this piece of code to control a shooting mechanism that works using six different motors.
if(vexRT[Btn7D] == 1)
{
motor[left_bttm] = 45;
motor[left_mid] = 45;
motor[left_top] = 45;
motor[right_bttm] = 45;
motor[right_mid] = 45;
motor[right_top] = 45;
wait1Msec(100);
}
else
{
motor[left_bttm] = 0;
motor[left_mid] = 0;
motor[left_top] = 0;
motor[right_bttm] = 0;
motor[right_mid] = 0;
motor[right_top] = 0;
}
if(vexRT[Btn7L] == 1)
{
motor[left_bttm] = 65;
motor[left_mid] = 65;
motor[left_top] = 65;
motor[right_bttm] = 65;
motor[right_mid] = 65;
motor[right_top] = 65;
wait1Msec(100);
}
else
{
motor[left_bttm] = 0;
motor[left_mid] = 0;
motor[left_top] = 0;
motor[right_bttm] = 0;
motor[right_mid] = 0;
motor[right_top] = 0;
}
if(vexRT[Btn7U] == 1)
{
motor[left_bttm] = 90;
motor[left_mid] = 90;
motor[left_top] = 90;
motor[right_bttm] = 90;
motor[right_mid] = 90;
motor[right_top] = 90;
wait1Msec(100);
}
else
{
motor[left_bttm] = 0;
motor[left_mid] = 0;
motor[left_top] = 0;
motor[right_bttm] = 0;
motor[right_mid] = 0;
motor[right_top] = 0;
}
Apparently, it works, but I for one am really confused as to how. Shouldn’t the motor values always reset to zero unless Btn7U is pushed, and if so, how do 7L and 7D work?
This is less a troubleshooting question and more of a “how did I get my programming knowledge wrong” question.
Thanks in advance for clearing up the confusion.