I have a problem with switching to the new software please help

please tell me what’s wrong with:

"#include “vex.h”

using namespace vex;

vex::motor ClawMotor = vex::motor(vex::PORT16);
vex::motor LeftMotor = vex::motor(vex::PORT19);
vex::motor RightMotor = vex::motor(vex::PORT1);
vex::motor Motor1 = vex::motor(vex::PORT4, true);
vex::motor Motor2 = vex::motor(vex::PORT14, true);
vex::controller Controller1 = vex::controller();
line LineSensor1 (Brain.ThreeWirePort.A);
line LineSensor2 (Brain.ThreeWirePort.A);
line LineSensor3 (Brain.ThreeWirePort.A);
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();

while (true)
{
LeftMotor.spin(directionType::rev, 50, vex::velocityUnits::pct);
RightMotor.spin(directionType::rev, 50, vex::velocityUnits::pct);

if (LineSensor1.value < 1000 && Linesensor3.value < 1000);
LeftMotor.stop(brakeType::coast);
RightMotor.stop(brakeType::coast);

}
}"

I found 3 issues here.
First, Linesensor3 isn’t an object. You forgot to capitalize it to match what you created, LineSensor3.

Second, value is a function and needs the parentheses and parameters to be called. it should look like this:
LineSensor1.value(pct)
pct is for percent, change it for your own use.

Finally, if statements need brackets to define the scope of the statement. Assuming you want to stop the motor when the if statement is true, your main function turns into this:

int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
  vexcodeInit();

  while (true) {
    LeftMotor.spin(directionType::rev, 50, vex::velocityUnits::pct);
    RightMotor.spin(directionType::rev, 50, vex::velocityUnits::pct);

    if (LineSensor1.value(pct) < 1000 && LineSensor3.value(pct) < 1000){
      LeftMotor.stop(brakeType::coast);
      RightMotor.stop(brakeType::coast);
    }
  }
}
4 Likes

Thank you for your expertise, and happy holidays!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.