Skip to content

Commit

Permalink
Added example
Browse files Browse the repository at this point in the history
  • Loading branch information
J3RN committed Jun 27, 2013
1 parent 829ab68 commit e42ea3f
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions Arduino/L3G4200D/Examples/L3G4200D_raw/L3G4200D_raw.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* A sketch to test the L3G4200D sensor
* AUTHOR: JONATHAN ARNETT
* MODIFIED: 02/04/2013
*/

#include <I2Cdev.h>
#include <L3G4200D.h>
#include <Wire.h>

L3G4200D gyro;

#define X 0
#define Y 1
#define Z 2

void setup() {
Wire.begin();
Serial.begin(9600);

// initialize
Serial.println("Initializing L3G4200D...");
gyro.initialize();

// test connection
Serial.println("Testing connection to device...");
Serial.println(gyro.testConnection() ? "L3G4200D connection successful" :
"L3G4200D connection failed");
}

void loop() {
bool indiv = 0;
String names[3] = {"x", "y", "z"};
int16_t data[3] = {0, 0, 0};

if (indiv) {
data[X] = gyro.getAngularVelocityX();
data[Y] = gyro.getAngularVelocityY();
data[Z] = gyro.getAngularVelocityZ();
} else {
gyro.getAngularVelocity(&data[X], &data[Y], &data[Z]);
}

for (int i = 0; i < 3; i++) {
Serial.print(names[i]);
Serial.print(" = ");
Serial.print(data[i]);
Serial.print(" ");
}

Serial.println();
delay(500);
}


0 comments on commit e42ea3f

Please sign in to comment.