I have 10 motors on my robot and a speaker and only four of the motors work.
These four motors are the drive train motors, and the speaker doesn’t functionally work.
It would help if you post your code. Place your code between the code tags so it’s easier for people to read. The code tags look a little like greater than and less than symbols above your “write a reply” box.
also make sure the motor controlers are good and no wires are clipped.
#pragma config(Motor, port2, left, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port3, right, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port4, punch, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port5, conveyor, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port6, rubber, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port7, lift, tmotorVex393_MC29, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main()
{
while(1==1)
{
motor[left] = vexRT[Ch3];
motor[right] = vexRT[Ch2];
}
//punch
while(1 == 1)
{
if(vexRT[Btn8U] == 1)
{
motor[punch] = 127;
}
else if(vexRT[Btn8D] == 1)
{
motor[punch] = -127;
}
else
{
motor[punch] = 0;
}
//conveyor
while(1 == 1)
{
if(vexRT[Btn6U] == 1)
{
motor[conveyor] = 127;
}
else if(vexRT[Btn6D] == 1)
{
motor[conveyor] = -127;
}
else
{
motor[conveyor] = 0;
}
//rubber
while(1 == 1)
{
if(vexRT[Btn6U] == 1)
{
motor[rubber] = 127;
}
else if(vexRT[Btn6D] == 1)
{
motor[rubber] = -127;
}
else
{
motor[rubber] = 0;
}
//lift
while(1 == 1)
{
if(vexRT[Btn5U] == 1)
{
motor[lift] = 127;
}
else if(vexRT[Btn5D] == 1)
{
motor[lift] = -127;
}
else
{
motor[lift] = 0;
}
//Speaker
while(1 == 1)
{
if(vexRT[Btn8L] == 1)
{
PlaySound(soundBeepBeep);
wait1Msec(200);
}
else if(vexRT[Btn8R] == 1)
{
PlayTone(440, 50);
wait1Msec(500);
}
else
{
motor[lift] = 0;
}
}
}
}
}
}
}
I also included the speaker code so when I press a button, It makes a sound.
It made two replies and I don’t know why…
You have while(1==1) statements embedded inside while(1==1) statements. This is bad. Once you enter such a loop, you won’t leave it without some break. So you won’t be able to do any of the other stuff. Only use the original while(1==1) statement, and erase the rest. That one will keep all of the joystick checks repeating forever.
@callen Now it’s power cycling itself (I think)
#pragma config(Motor, port2, left, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port3, right, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port4, punch, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port5, conveyor, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port6, rubber, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port7, lift, tmotorVex393_MC29, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main()
{
while(1==1)
{
motor[left] = vexRT[Ch3];
motor[right] = vexRT[Ch2];
}
//punch
{
if(vexRT[Btn8U] == 1)
{
motor[punch] = 127;
}
else if(vexRT[Btn8D] == 1)
{
motor[punch] = -127;
}
else
{
motor[punch] = 0;
}
//conveyor
{
if(vexRT[Btn6U] == 1)
{
motor[conveyor] = 127;
}
else if(vexRT[Btn6D] == 1)
{
motor[conveyor] = -127;
}
else
{
motor[conveyor] = 0;
}
//rubber
{
if(vexRT[Btn6U] == 1)
{
motor[rubber] = 127;
}
else if(vexRT[Btn6D] == 1)
{
motor[rubber] = -127;
}
else
{
motor[rubber] = 0;
}
//lift
{
if(vexRT[Btn5U] == 1)
{
motor[lift] = 127;
}
else if(vexRT[Btn5D] == 1)
{
motor[lift] = -127;
}
else
{
motor[lift] = 0;
}
//Speaker
{
if(vexRT[Btn8L] == 1)
{
PlaySound(soundBeepBeep);
wait1Msec(200);
}
else if(vexRT[Btn8R] == 1)
{
PlayTone(440, 50);
wait1Msec(500);
}
else
{
motor[lift] = 0;
}
}
}
}
}
}
}
I only left one “while(1==1)”
UPDATE: Still… The drive train is the one that is still working… Everything else is not…
Now fix your braces. Open it after the while(1==1) as you have but don’t close that one until the very end instead of right after the motor[left] and motor[right] commands. (So erase that closing brace.) Also, clean up the rest of them. You have a whole bunch of opening braces before the if-then statements that shouldn’t be there, and then you’ve closed the bunch of them at the end. Those may not mess you up, but they’re bad practice if they don’t.
#pragma config(Motor, port2, left, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port3, right, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port4, punch, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port5, conveyor, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port6, rubber, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port7, lift, tmotorVex393_MC29, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main()
{
while(1==1)
motor [left] = vexRT[Ch3];
motor [right] = vexRT[Ch2];
//punch
if (vexRT [Btn8U] == 1)
{
motor [punch] = 127;
}
else if(vexRT[Btn8D] == 1)
{
motor[punch] = -127;
}
else
{
motor[punch] = 0;
}
//conveyor
if(vexRT[Btn6U] == 1)
{
motor[conveyor] = 127;
}
else if(vexRT[Btn6D] == 1)
{
motor[conveyor] = -127;
}
else
{
motor[conveyor] = 0;
}
//rubber
if(vexRT[Btn6U] == 1)
{
motor[rubber] = 127;
}
else if(vexRT[Btn6D] == 1)
{
motor[rubber] = -127;
}
else
{
motor[rubber] = 0;
}
//lift
if(vexRT[Btn5U] == 1)
{
motor[lift] = 127;
}
else if(vexRT[Btn5D] == 1)
{
motor[lift] = -127;
}
else
{
motor[lift] = 0;
}
//Speaker
if(vexRT[Btn8L] == 1)
{
PlaySound(soundBeepBeep);
wait1Msec(200);
}
else if(vexRT[Btn8R] == 1)
{
PlayTone(440, 50);
wait1Msec(500);
}
else
{
motor[lift] = 0;
}
}
Now only the left side of the drive train is working…
You missed some of what I wrote. You needed to keep the opening brace immediately after while(1==1). Without that you only repeat forever the one command after it. So put that opening brace in. Then you’ll repeat everything until the closing brace. So you want the matching closing brace to be at the very end.
Ahh!! Thank you so much!!