Using the VEX IQ (1st gen) Gyro Sensor

A Gyro is commonly used for navigation. By tracking how fast and which way a robot is turning, it can determine the direction your robot is facing.

The VEX IQ Gyro Sensor is included in the VEX IQ Super Kit but it can also be purchased here.


Description of the Gyro Sensor

The Gyro Sensor can be used to keep the robot driving straight and also to make accurate turns. If you want a robot to drive to a location then turn around and return to the same spot, you will need to move straight for an accurate distance, turn exactly 180 degrees, then drive back straight for the same distance. A Gyro Sensor makes keeping straight and turning very accurate. 

This sensor measures its own rotation around an axis. Whenever this sensor is rotated in the direction indicated by the symbol on the top of it, it measures the angle of the turn. The returned measure is in degrees either clockwise or counterclockwise. As the curved arrow on the top of the sensor indicates, the values increase as the Gyro Sensor turns counterclockwise. The values decrease as it turns clockwise.  


How the Gyro Sensor Works

The Gyro Sensor only detects movements that are clockwise or counterclockwise on the axis indicated on the top of the sensor. So if the gyro is mounted horizontally in the center of the robot, it does not detect if the robot is tilted downward or upward on a slope as long as the gyro hasn’t turned clockwise or counterclockwise. It also does not detect if the robot is tilted or leaning on one side as long as it is still oriented forward. However, a Gyro Sensor can be mounted on a robot’s side or on a manipulator and that would allow it to measure tilt.  


Common Uses of the Gyro Sensor

Gyro sensors are integrated into many pieces of technology where knowing the orientation of a device or stabilizing an object are important.

Some common uses in daily life include:

  • Gyro sensors are integrated into small motorized vehicles that allow the person to control speed by leaning forward and backward, while also keeping the vehicle stable.
  • Gyro Sensors are used to stabilize large ships as well as monorail trains, in order to keep the people and cargo on them safe.
  • Gyro sensors are used to measure movement in some handheld electronic devices, such as video game remote controls.

Some common uses for a Gyro Sensor with a VEX IQ Robot include:

  • Detecting if the robot has turned left or right

  • Detecting whether the robot is tilting up or down by mounting it on the side of the robot

  • Maintaining straight driving
  • Making accurate turns

Gyro Sensors on a Competition Robot

The Gyro Sensor can be important for programming a robot for competitions. The gyro is especially important when programming for the autonomous period when the robot has to perform tasks without human input. 

The Gyro Sensor can make a competition robot better in the following ways:

  • The Gyro Sensor can detect which direction and how far the robot has turned from its starting point.
  • The Gyro Sensor can detect if the robot is tilting up or down by mounting it on the side of the robot.
  • The Gyro Sensor can be used to detect the status of one of the robot's components (e.g., arm up, arm down, etc) by mounting it on the manipulator or attachment.

Using a Gyro Sensor in VEXcode IQ

Using a Gyro Sensor as Part of a Drivetrain

When using a Drivetrain on your VEX IQ robot, the Gyro Sensor is built into the Drivetrain, and works automatically to ensure that the robot does things like drive straight and make accurate turns. 

Diagram illustrating various sensors used in the VEX IQ Robotics platform, including descriptions of each sensor's function and application in educational robotics projects.

When configuring your Drivetrain in VEXcode IQ, you will be prompted to include the Gyro Sensor as part of the configuration, as shown in this example image. 

There are many benefits to using the Gyro Sensor as part of the Drivetrain. The Gyro Sensor will automatically be calibrated when the robot is coded with Drivetrain commands, and the Drivetrain commands will use the data from the Gyro Sensor to ensure that the robot drives and turns accurately. You do not need to code the Gyro Sensor separately from the Drivetrain in this case, making your project simpler. 

Diagram illustrating various sensors used in the VEX IQ Robotics platform, showcasing their placement and functionality for educational robotics projects.

The Accurate Turns example project in VEXcode IQ can be used to show how to use the Gyro Sensor to turn the robot using heading and rotation values.

For information on how to open an example project in VEXcode IQ, see one of the following articles.

Coding a Gyro Sensor Separately From a Drivetrain

You can add a Gyro Sensor outside of a Drivetrain, using Gyro Sensing commands.

Diagram illustrating the various sensors used in the VEX IQ Robotics platform, highlighting their functions and connections for educational robotics projects.

When coding a separate Gyro Sensor, you must be sure to calibrate the sensor using a [Calibrate Gyro] block or a Calibrate gyro Python or C++ command at the start of the project, to ensure that the Gyro Sensor behaves as expected. 

When calibrating is taking place, be sure that the robot is completely stationary and not moving, so that the calibration is successful and accurate. 

Diagram illustrating the various sensors used in the VEX IQ Robotics platform, showcasing their placement and functionality to enhance robot performance in educational robotics projects.

When coding a separate Gyro Sensor you can use Set Gyro commands, like those shown here for blocks, Python, and C++, to do things like set the current sensor position as the heading or rotation value. 

To learn more about individual commands that can be used to code a Gyro Sensor, view the Help in VEXcode IQ Blocks or the Help in VEXcode IQ Python.

Diagram illustrating various sensors used in the VEX IQ Robotics platform, showcasing their placement and functionality to enhance robot performance in educational robotics projects.

The Gyro Sensing example project in VEXcode IQ can be used to show what the values of the Gyro Sensor are. This is good to use independently of a drivetrain to understand how the values change as the sensor moved.

For information on how to open an example project in VEXcode IQ, see one of the following articles.

For more information, help, and tips, check out the many resources at VEX Professional Development Plus

Last Updated: