Hi :)recently a bought MinIMU-9 Gyro, Accelerometer, and Compass and now i am testing it but there is someting i can't understand.Here is my source :
#include <Wire.h>
#include <L3G.h>
#include <LSM303.h>
L3G gyro;
LSM303 compass;
void setup() {
Serial.begin(9600);
Wire.begin();
if (!gyro.init())
{
Serial.println("Failed to autodetect gyro type!");
while (1);
}
gyro.enableDefault();
compass.init();
compass.enableDefault();
}
void loop() {
gyro.read();
compass.read();
Serial.print("A ");
Serial.print("X: ");
Serial.print((int)compass.a.x);
Serial.print(" Y: ");
Serial.print((int)compass.a.y);
Serial.print(" Z: ");
Serial.print((int)compass.a.z);
Serial.print("G ");
Serial.print("X: ");
Serial.print((int)gyro.g.x);
Serial.print(" Y: ");
Serial.print((int)gyro.g.y);
Serial.print(" Z: ");
Serial.println((int)gyro.g.z);
Serial.print(" M ");
Serial.print(" X: ");
Serial.print((int)compass.m.x);
Serial.print(" Y: ");
Serial.print((int)compass.m.y);
Serial.print(" Z: ");
Serial.println((int)compass.m.z);
delay(100);
}
and i receive all the values but they are changing withouT me moving the sensor or anityng else .The sensor and my arduino board are on the floor . Here is what i get in serial monitor
A X: -31 Y: -1 Z: 967 G X: 23 Y: -86 Z: 43
M X: -199 Y: -280 Z: -376
A X: -19 Y: 12 Z: 943 G X: 16 Y: -90 Z: 61
M X: -197 Y: -282 Z: -380
A X: -48 Y: 6 Z: 959 G X: 24 Y: -87 Z: 41
M X: -188 Y: -271 Z: -378
A X: -41 Y: 11 Z: 961 G X: 27 Y: -52 Z: 64
M X: -202 Y: -282 Z: -377
A X: -35 Y: 6 Z: 959 G X: 22 Y: -62 Z: 54
M X: -193 Y: -276 Z: -379
A X: -25 Y: 6 Z: 958 G X: 7 Y: -81 Z: 67
M X: -199 Y: -281 Z: -377
A X: -13 Y: 1 Z: 975 G X: 19 Y: -81 Z: 18
M X: -197 Y: -279 Z: -379
A X: -27 Y: 6 Z: 937 G X: 48 Y: -51 Z: 73
M X: -191 Y: -272 Z: -378
Does someone now how to fix this?Here is the board in pololu website
Thanx.