Questions about the callback command in vex code text

I’ve been trying to get this program to work but I honestly don’t know what I’m doing. The idea is that this motor moves on its own until you hold A, but when you release button A, it starts up again. I’m not entirely sure if I’m going at this problem head-on or what though. Don’t worry about the comments, they mean nothing, I only used an example to know what I was doing.

here’s the file: https://drive.google.com/open?id=16S80bRAS_6lXsJvAnQVRZOm22Pgn0h4j

I think youre trying to use button.pressed(callback());

When you should be using
button.pressing();

1 Like

The first thing I noticed in your code was that your loop runs only so long the left button is being held down from the moment the code is started. If at any moment you let go your code ends. I’m going to have to assume that you don’t want that - that while statement can just be

While(true){

}

Next, one option you have is to just check if the a button is pressing. If it isn’t, turn on the motor.

1 Like

I honestly don’t think that helps with trying to make the callback system work, but I guess it does solve one problem

I don’t even know what I’m doing. I’m way just too under-experienced
(sorry)

Don’t worry, we’re here to help :smile:

Here’s an excerpt from some of my old code, the logic is a bit reversed for you, but this is the idea:

      // Arm Control
      // Use L1 and L2 buttons for directional actuation, if no button is pressed, turn off motor
      if (Controller1.ButtonL1.pressing()) {
        ArmMotor.spin(directionType::fwd, 100, velocityUnits::pct);
      }
      else if (Controller1.ButtonL2.pressing()) {
        ArmMotor.spin(directionType::fwd, -100, velocityUnits::pct);
      }
      else {
        ArmMotor.stop();
      }
1 Like