-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10dofmeter.ino
72 lines (52 loc) · 1.32 KB
/
10dofmeter.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* read all sensor values */
#include <Wire.h> //I2C Arduino Library
#include "gyro.h"
#include "compass.h"
#include "BMP085.h"
#define gyro 0x69 // L3G4200D
#define acc 0x53 // ADXL345
#define comp 0x1E // HMC5883
#define baro 0x77 // BMP085
// forward declarations
void readAccelerometer(Vector3 *data);
// variables
Vector3 compData;
Vector3 gyroData;
Vector3 accData;
BMP085 calibrationData;
float temp;
unsigned long pressure;
void setup(){
//Initialize Serial and I2C communications
Serial.begin(9600);
Wire.begin();
initCompass(comp);
initGyro(gyro);
// setup ADXL345(accelerometer)
// TODO
// setup BMP085
initBMP085(baro, &calibrationData);
}
void loop(){
readCompass(comp, &compData);
readGyro(gyro, &gyroData);
readAccelerometer(&accData);
unsigned int rawTemp;
readTemperature(baro, &rawTemp);
unsigned long rawPressure;
readPressure(baro, &rawPressure);
temp = getTemperature(rawTemp, &calibrationData);
pressure = getPressure(rawPressure, &calibrationData);
Serial.print("Compass: ");
printVector(&compData);
Serial.print("Gyroscope: ");
printVector(&gyroData);
Serial.print("Temperature: ");
Serial.println(temp);
Serial.print("Pressure: ");
Serial.println(pressure);
delay(1000);
}
void readAccelerometer(Vector3 *data) {
// TODO
}