How can translate a button toggle in blocks to vex code pro competition template

I am trying to make my code into a C++ project but have a 6 motor drive so when trying to configure the drivetrain in the robot-config.cpp I had to enable expert robot configuration so I’ve been trying to make my intake motor (PORT7) move forward whenever I press the button L1 and reverse when I press L2 but stop when I release the button.

This is the blocks project i want to convert into C++

Your block code has a flaw. The code will stay in the first forever loop and won’t reach the second forever loop. Just put everything in one forever loop.

while (true) {
  if (Controller1.ButtonL1.pressing()) {
    INTAKE.spin(forward);
  }
  else if (Controller1.ButtonL2.pressing()) {
    INTAKE.spin(reverse);
  }
  else {
    INTAKE.stop();
  }
}
1 Like

Thank you so much you don’t know how much this is going to help me when coding for my robot auton :slight_smile:

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