So I bought this accelero/gyro combo from sparkfun and I want to know how I can get separate values from both sensors.
sensor: SparkFun 6 Degrees of Freedom IMU Digital Combo Board - ITG3200/ADXL345 - SEN-10121 - SparkFun Electronics
I followed the tutorial on bildr and that works just fine.
tutorial: http://bildr.org/2012/03/stable-orientation-digital-imu-6dof-arduino/
Now I'm pretty new to libraries but I think I get how they work by looking at the example at bildr. So I wrote some code and it uploads to my arduino just fine, but the serial monitor only gives 0's.
This is the code I wrote:
#include <FIMU_ADXL345.h>
#include <FIMU_ITG3200.h>
#include <Wire.h>
float AccRead[3]; // X, Y, Z
float GyroRead[3]; // yaw, pitch, roll
// Set the Accelerometer
ADXL345 Acc = ADXL345();
// Set the Gyroscope
ITG3200 Gyro = ITG3200();
void setup() {
Serial.begin(9600);
Wire.begin();
delay(5);
Acc.init(0); //begin the IMU
Gyro.init(0);
delay(5);
}
void loop() {
Acc.get_Gxyz(AccRead);
Gyro.readGyro(GyroRead);
Serial.print(AccRead[0]);
Serial.print(" | ");
Serial.print(AccRead[1]);
Serial.print(" | ");
Serial.print(AccRead[2]);
Serial.print(" || ");
Serial.print(GyroRead[0]);
Serial.print(" | ");
Serial.print(GyroRead[1]);
Serial.print(" | ");
Serial.println(GyroRead[2]);
delay(100);
}
The libraries I used can also be found on the bildr page, but the functions I used are described like this in the libraries:
FIMU_ADXL345.H:
void init(int address);
void get_Gxyz(float *xyz);
FIMU_ITG3200.h:
void init(unsigned int address);
void readGyro(float *_GyroXYZ); // includes gain and offset
I don't know if it makes any difference but I use a Leonardo.
Can anybody help me make this work?