-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsensor_data.ino
More file actions
43 lines (36 loc) · 867 Bytes
/
sensor_data.ino
File metadata and controls
43 lines (36 loc) · 867 Bytes
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
// collect sensor data gyroscope
#include <Wire.h>
#include <SparkFunLSM9DS1.h>
LSM9DS1 imu;
unsigned long time;
void setup() {
Serial.begin(115200);
Wire.begin();
imu.begin();
}
void loop() {
time = millis();
if ( imu.accelAvailable() )
imu.readAccel();
if ( imu.gyroAvailable() )
imu.readGyro();
float ax = imu.calcAccel(imu.ax);
float ay = imu.calcAccel(imu.ay);
float az = imu.calcAccel(imu.az);
float gx = imu.calcGyro(imu.gx);
float gy = imu.calcGyro(imu.gy);
float gz = imu.calcGyro(imu.gz);
// Serial.print(ax);
// Serial.print("\t");
// Serial.print(ay);
// Serial.print("\t");
// Serial.print(az);
// Serial.print("\t");
Serial.print(gy);
Serial.print(",");
Serial.print(gz);
Serial.print(",");
Serial.print(gx);
Serial.println();
delay(50);
}