Gyro

Here are some hints/help when using the LEGO MINDSTORMS Gyro Sensor.

1. Use .value() to read the value

Here is some example code for reading 10 gyro sensor values (angle). While this program was running, I was turning the gyro sensor forwards and then backwards.

Image

2. Resetting (calibrating) the gyro

Sometimes, in the middle of your code, you want to say "where the gyro is right now, consider that to be 0-degrees."  There is no explicit function for resetting, but if you change modes it will reset the gyro back to zero.  Note that you want to make sure the sensor is STILL (not moving) when you reset, else you will get drift in your new readings.

Image

Here are the files: