Gyro spins in circles

How do I turn using the gyro? I want the bot to make a 90 degree turn to the right, but everything we do just makes the bot spin in circles.
I had it print what the gyro was seeing on a different code to make sure it worked, which it does. It displayed what seemed to be accurate value from 0 to 360 degrees.
I tried the same thing inside the autonomous code and it displayed values to 900 something, exactly what it was I forget.

Through all of this, it still hasn’t relented spinning in circles, it’s making me dizzy.

Will you share your code?

(Use ``` before and after the text block so it formats it correctly)

// Include the V5 Library

#include "vex.h"


// Allows for easier use of the VEX Library

using namespace vex;


float myVariable;


// "when started"

void preAutonomous(void) {

//Gryo setup



  GyroG.setHeading (0.0, degrees);

  Drivetrain.setDriveVelocity(10.0, percent);

  Drivetrain.setTurnVelocity(10.0, percent);


  Arm.setVelocity(100.0, percent);

  Arm.setMaxTorque(100.0, percent);

  Feeder.setMaxTorque(50.0, percent);

  Feeder.setVelocity(60.0, percent);





// "when Controller1 ButtonUp pressed"

void onevent_Controller1ButtonUp_pressed_0() {





void autonomous(void) {


  Drivetrain.setDriveVelocity(20, percent);

  Drivetrain.setTurnVelocity(20, percent);


Drivetrain.driveFor(forward, 6, inches);


GyroG.setHeading (0.0, degrees);


// turning right


while (GyroG.value(rotationUnits::deg)<=210.0) {

  Brain.Screen.printAt(20,80, "Gyro");

  Brain.Screen.printAt(20,120, "Reading =%f", GyroG.rotation(degrees));









void userControl(void) {




int main() {

  // create competition instance

  competition Competition;


  // Set up callbacks for autonomous and driver control periods.





// Calibrate the Drivetrain Gyro



task rc_auto_loop_task_Controller1(rc_auto_loop_function_Controller1);

  wait(15, msec);

  // post event registration


  // wait for rotation sensor to fully initialize

  wait(30, msec);

  // Run the pre-autonomous function.



  // Prevent main from exiting with an infinite loop.

  while (true) {

    wait(100, msec);



Oh cool, it worked

Looks like you’re only calibrating the inertial sensor for 0.1 seconds - the recommended time per this page is 2 seconds.

The code you posted seems to have the robot turning right 210 degrees, rather than 90 as you suggested above – is that intentional?

Additionally, you could use smartdrive::turnFor rather than just turning manually until the gyro value passes a threshold.


I’m actually not using an inertial sensor, what’s on the bot is a gyroscope we bought 3 years ago.

Same concept though, you need to wait until calibration finishes.


This happened to me in IQ as well. Simple fix. Our gyro must be upside down for it to work. If we put it upright, then it will just spin in circles. When we turned it upside down, it worked perfectly. Shouldnt be an issue with code

That heavily implies that your negative signs are flipped, e.g. you’re trying to spin to -90, but you’re turning in the positive direction, so the gyro can never hit that threshold. By inverting the gyro, you reverse which direction of robot rotation corresponds to a positive gyro movement.


i have no idea what ur saying (no offence) but all i know is that it worked perfectly when i flipped it

I’m pretty sure our gyro was mounted upside down. Not necessary on purpose, but more due to packaging constraints.
Also, we ended up swapping out the gyro for the inertial sensor we had, which immediately worked.