A library to interface Arduino code with the 3 Axis L3G4200D gyroscope.
Wire.begin(); gyro.initialize(2000); Serial.begin(9600);In the main loop we get X, Y, and Z orientations with the get functions, for example:
x = gyro.getX();Then we spit these values out on the serial port wait 300 milliseconds and repeat. See the whole example sketch and grab the library from the download section below.
/* LucidTronix L3G4200D Gyroscope Library * For instructions, details and schematic, See: * http://www.lucidtronix.com/tutorials/63 */ #include#include L3G4200D gyro;int x, y, z;void setup(){ Wire.begin(); gyro.initialize(2000); Serial.begin(9600);}void loop(){ x = gyro.getX(); Serial.print("X:"); Serial.print(x); y = gyro.getY(); Serial.print(" Y:"); Serial.print(y); z = gyro.getZ(); Serial.print(" Z:"); Serial.println(z); delay(300); //Just here to slow down the serial to make it more readable}
Comments: