Turn left example in VexCode Text Not working

We built the claw bot. and when we opened the example for turn left, the robot just keeps turning left and never stops.

Perhaps you didn’t wire it correctly and the ports are reversed, as the two motor ms turn opposite of each other, when wired incorrectly they will never reach their target.

No we checked that, we reversed the ports. Instead of turning left, it turned right.

That’s odd, okay are you sure the example isn’t to just make it turn left continuously? Is there a motor rotate for function?

#include “vex.h”

using namespace vex;

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

// Drives robot forward 6 inches at the default 50% velocity
Drivetrain.driveFor(6, inches);
wait(1, sec);

// Drives the robot in reverse for 6 inches at 90% velocity
Drivetrain.setDriveVelocity(90, percent);
Drivetrain.driveFor(-6, inches);
wait(1, seconds);

// Turns the robot 90 degrees to the right at the default 50% velocity
Drivetrain.turnFor(90, degrees);
wait(1, seconds);

// Turns the robot to the left at 25% velocity
Drivetrain.setTurnVelocity(25, percent);
Drivetrain.turnFor(-90, degrees);
}

Moves forward, then reverse. Turns right indefinitely

Try changing the turn for to 90 degrees rather than negative.

tried that to also. i feel like its nor reading the sensor. We tried two different claw bots

Does it have the Gyro set to a port on the DriveTrain Configuration? If so, is the gyro present on that port?

image

Im not sure maybe the example doesn’t work in the first place, I haven’t used Vexcode, but maybe the motors haven’t initialized properly. It says that it still initializing

Thats what it was. Thank you.

Sorry i didn’t realize that before.

Was it the initialization or the gyro that fixed the issue?

Gyro, i forgot to select no gyro.
Thanks

1 Like