Backleftmotor.spin(vex::directionType::fwd, Controller1.Axis3.value()/2, vex::velocityUnits::pct); //Tank Control : Motor runs at half speed
Backrightmotor.spin(vex::directionType::fwd, Controller1.Axis2.value()/2, vex::velocityUnits::pct); //Tank Control : Motor runs at half speed
if(Controller1.ButtonX.pressing()) // ARM1 motor runs for half speed when B is pressed
{
Arm1.spin(vex::directionType::fwd, 75, vex::velocityUnits::pct); // 3/4th
}
else
{
Arm1.stop(vex::brakeType::hold);
}
if(Controller1.ButtonB.pressing()) // ARM1 motor runs when Button B is being pressed.
{
Arm2.spin(vex::directionType::fwd, 75, vex::velocityUnits::pct); // Motor run at 3/4th speed
}
else
{
Arm2.stop(vex::brakeType::hold); //holds the arm where it is stopped
}
if(Controller1.ButtonUp.pressing())//Claw motor should run if Button Up is being pressed
{
Claw1.spin(vex::directionType::fwd, 75,vex::velocityUnits::pct);//Motor will run at 3/4th speed
}
else
{
Claw1.stop(vex::brakeType::hold);//if the button is not being pressed.
}
if(Controller1.ButtonUp.pressing())//If that button is being pressed
{
Claw2.spin(vex::directionType::fwd,75,vex::velocityUnits::pct);//the motor wil run at 3/th speed
}
else
{
Claw2.stop(vex::brakeType::hold);//The motor will stop if it is not pressed.
}
It would help a lot if you used the code tags when posting.
The big problems I see are the following:
Your code doesn’t match your comments, so I’m not sure it does what you want. Look at ARM1 v. ARM2 and ButtonX v. ButtonB.
You don’t have any ways to run most those motors in other directions. Is that really what you want, to only run each of those arm/claw motors only in a single direction ever?
In addition to the monodirectional arm and claw motor problem identified by @callen, you are also setting both motors in two places. Even if one of them was able to send a reverse signal to those motors, they would fight for control as it would be setting one value then immediately overwriting it with another value. Instead of using two separate
if...else
structures for each motor you should be using a single
Are you sure? The comments said this, but I never spotted an actual instance of it. That’s why I said the code doesn’t match the comments.
Really? Arm1, Arm2, Claw1, and Claw2 ran in both directions? With exactly this code? Not Backleftmotor and Backrightmotor, as those should run in both directions.
Backleftmotor.spin(vex::directionType::fwd, Controller1.Axis3.value()/2, vex::velocityUnits::pct); //Tank Control : Motor runs at half speed
Backrightmotor.spin(vex::directionType::fwd, Controller1.Axis2.value()/2, vex::velocityUnits::pct); //Tank Control : Motor runs at half speed
if(Controller1.ButtonX.pressing()) // ARM1 motor runs for half speed when B is pressed
{
Arm1.spin(vex::directionType::fwd, 75, vex::velocityUnits::pct); // 3/4th
}
else
{
Arm1.stop(vex::brakeType::hold);
}
if(Controller1.ButtonB.pressing()) // ARM1 motor runs when Button B is being pressed.
{
Arm2.spin(vex::directionType::fwd, 75, vex::velocityUnits::pct); // Motor run at 3/4th speed
}
else
{
Arm2.stop(vex::brakeType::hold); //holds the arm where it is stopped
}
if(Controller1.ButtonUp.pressing())//Claw motor should run if Button Up is being pressed
{
Claw1.spin(vex::directionType::fwd, 75,vex::velocityUnits::pct);//Motor will run at 3/4th speed
}
else
{
Claw1.stop(vex::brakeType::hold);//if the button is not being pressed.
}
if(Controller1.ButtonUp.pressing())//If that button is being pressed
{
Claw2.spin(vex::directionType::fwd,75,vex::velocityUnits::pct);//the motor wil run at 3/th speed
}
else
{
Claw2.stop(vex::brakeType::hold);//The motor will stop if it is not pressed.
}
Looks like you posted the same or very nearly the same code. As I said, what you’ve posted and what you’re describing are not the same code. Look at what you said for ArM1.
Look at what your code says for Arm1 and Arm2.
Arm1 is being controlled by only button X. Meanwhile, button B is actually controlling Arm2.
It makes it very hard for us to help you when you’re posting different code than what you’re describing the robot using.
So will this code be better? We added the fwd and rev
#include “robot-config.h”
int main()
{
while(true)
{
Backleftmotor.spin(vex::directionType::fwd, Controller1.Axis3.value()/2, vex::velocityUnits::pct); //Tank Control : Motor runs at half speed
Backrightmotor.spin(vex::directionType::fwd, Controller1.Axis2.value()/2, vex::velocityUnits::pct); //Tank Control : Motor runs at half speed
if(Controller1.ButtonX.pressing()) // ARM1 motor runs for half speed when B is pressed
{
Arm1.spin(vex::directionType::fwd, 75, vex::velocityUnits::pct); // 3/4th
if(Controller1.ButtonUp.pressing())//Claw motor should run if Button Up is being pressed
{
Claw1.spin(vex::directionType::fwd, 75,vex::velocityUnits::pct);//Motor will run at 3/4th speed
}
else
{
Claw1.stop(vex::brakeType::hold);//if the button is not being pressed.
}
if(Controller1.ButtonUp.pressing())//If that button is being pressed
{
Claw2.spin(vex::directionType::fwd,75,vex::velocityUnits::pct);//the motor wil run at 3/th speed
}
else
{
Claw2.stop(vex::brakeType::hold);//The motor will stop if it is not pressed.
}