Lesson: Exercise: Using a Gyro

Explore using the Gyroscope Sensor device to gather information about the robot's environment.

Understand how to use the Gyroscope Sensor to gather information about the robot's environment.


Modern Robotics has an gyroscopic sensor designed for use with the Tetrix control system. This sensor can return heading and rate of rotation information. Here is a detailed discussion of the Gyro sensor on the Modern Robotics website. There are links on the page to programming information. This is recommended viewing. Note that the REV hub has a built-in gyro as part of its IMU discussed in the next lesson.

If you use the MR Gyro with the REV Hub the gyro is plugged into an I2C port and configured by adding the device to the I2C Bus number matching the physical I2C port you plugged the sensor into.

Below is a simplified sample program that uses a gyro to drive in a straight line and avoid obstacles by backing up from contact with an obstacle and turing 90 degress and resuming driving in the new direction. You can paste it into AS and experiment with it.