Plz check my code

while(true){
Arm1.spin(vex::directionType::fwd, Controller1.ButtonX.value(), vex::velocityUnits::pct); //(ButtonX)/2
Arm2.spin(vex::directionType::fwd, Controller1.ButtonB.value(), vex::velocityUnits::pct); //(ButtonB)/2

says there is something wrong with it.

The vex::controller::button class does not have a value(void) method that I can recall. Try replacing


Controller1.ButtonX.value()

with


Controller1.ButtonX.pressing() ? 100: 0

and a similar change for ButtonB. You can change the 100 to whatever % you want the motor to spin at.

Ok but it only said that one line was incorrect

Some compilers only flag the first fatal error. I’d have to see the actual error message to be of any further assistance.

Okay thankyou. Would #include “robot-config.h”

int main() {

using namespace vex;

vex::brain Brain;
vex::motor Backleftmotor (vex::PORT1, vex::gearSetting::ratio18_1, true);
vex::motor Backrightmotor (vex::PORT2, vex::gearSetting::ratio18_1, true);

while(true){
    Backleftmotor.spin(vex::directionType::fwd, Controller1.Axis3.value(), vex::velocityUnits::pct); //(Axis3+Axis4)/2
    Backrightmotor.spin(vex::directionType::fwd, Controller1.Axis2.value(), vex::velocityUnits::pct);//(Axis1+Axis2)/2
    
    vex::task::sleep(20); 
}

vex::motor Arm1 (vex::PORT6, vex::gearSetting::ratio18_1, true);
vex::motor Arm2 (vex::PORT7, vex::gearSetting::ratio18_1, true);

while(true){
    Arm1.spin(vex::directionType::fwd, Controller1.ButtonX.value(), vex::velocityUnits::pct); //(Axis3+Axis4)/2
    Arm2.spin(vex::directionType::fwd, Controller1.ButtonB.value(), vex::velocityUnits::pct); //(ButtonB)/2

is it correct? we worked on it a bit more and it says the error message next to the arm code.

This may be the problem, you are using namespace vex but then are using vex:: in the code. Try getting rid of the using namespace vex line. Also, your arm code is not in the main task and the while true statement for the arm code needs to be closed. In other words, try getting rid of the using vex namespace line and closing the code.

No problem having vex::

@John Tyler explained that ButtonX and ButtonB do not have a value() method, use pressing(), it will return true or false. See the API here
http://help.vexcodingstudio.com/#cpp/namespacevex/classvex_1_1controller_1_1button/pressing

Ok thanks so much. Hope that will work.

As explained Button.Value() is not a valid sensing Boolean for buttons. They are valid only for Joystick Axes. Assuming you have your motors configured correctly …the code below should work

#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 you Button X pressing
{
Arm1.spin(vex::directionType::fwd, 50, vex::velocityUnits::pct); // Motor run at half speed

}
else
{
Arm1.stop(vex::brakeType::hold);

}
if(Controller1.ButtonB.pressing()) // ARM1 motor runs for half speed when you Button B pressing
{
Arm2.spin(vex::directionType::fwd, 50, vex::velocityUnits::pct); // Motor run at half speed

}
else
{
Arm2.stop(vex::brakeType::hold); //holds the arm where it is stopped

}

}
}

Thankyou so much. Brackets were confusing in the beginning.

WIll button B and X and All the 4 axis’s work?

Looks like two different threads were created, the other starting partway through this one. Here is what I answered in the other: