Subversion Repositories FlightCtrl

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1993 - 1
// ITG-3200_test
2
// Copyright 2010-2011 Filipe Vieira & various contributors.
3
// http://code.google.com/p/itg-3200driver
4
// Simple test of gyro sensors output using default settings.
5
 
6
#include <Wire.h>
7
#include <ITG3200.h>
8
 
9
ITG3200 gyro = ITG3200();
10
float  x,y,z,temperature;
11
int ix, iy, iz;
12
 
13
void setup(void) {
14
  Serial.begin(9600);
15
  Wire.begin();      // if experiencing gyro problems/crashes while reading XYZ values
16
                     // please read class constructor comments for further info.
17
  delay(1000);
18
  // Use ITG3200_ADDR_AD0_HIGH or ITG3200_ADDR_AD0_LOW as the ITG3200 address
19
  // depending on how AD0 is connected on your breakout board, check its schematics for details
20
  gyro.init(ITG3200_ADDR_AD0_HIGH);
21
 
22
  Serial.print("zeroCalibrating...");
23
  gyro.zeroCalibrate(2500, 2);
24
  Serial.println("done.");
25
}
26
 
27
void loop(void) {
28
  while (gyro.isRawDataReady()) {
29
    /*
30
    // Reads uncalibrated raw values from the sensor
31
    gyro.readGyroRaw(&ix,&iy,&iz);
32
    Serial.print("X:");
33
    Serial.print(ix);
34
    Serial.print("  Y:");
35
    Serial.print(iy);
36
    Serial.print("  Z:");
37
    Serial.print(iz);
38
    */
39
 
40
    /*
41
    // Reads calibrated raw values from the sensor
42
    gyro.readGyroRawCal(&ix,&iy,&iz);
43
    Serial.print("X:");
44
    Serial.print(ix);
45
    Serial.print("  Y:");
46
    Serial.print(iy);
47
    Serial.print("  Z:");
48
    Serial.print(iz);
49
    */
50
 
51
    // Reads calibrated values in deg/sec
52
    gyro.readTemp(&temperature);
53
    gyro.readGyro(&x,&y,&z);
54
    Serial.print("X:");
55
    Serial.print(x);
56
    Serial.print("  Y:");
57
    Serial.print(y);
58
    Serial.print("  Z:");
59
    Serial.print(z);
60
    Serial.print("  T:");
61
    Serial.println(temperature);
62
  }
63
}
64
 
65
 
66