-
Notifications
You must be signed in to change notification settings - Fork 1
/
STEAMRnE_30.ino
65 lines (51 loc) · 1.18 KB
/
STEAMRnE_30.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
#include "define.h"
#include <Wire.h>
#include <I2Cdev.h>
#include <MPU6050.h>
#include <TimeLib.h>
#include <DS1307RTC.h>
DATA data;
MPU6050 mpu;
tmElements_t tm;
int16_t ax, ay, az, gx, gy, gz;
int vx, vy, vz;
int fx, fy, fz;
String Time = "None.";
String acc = "";
String output = "";
bool first = 1;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
while (!Serial);
Wire.begin();
mpu.initialize();
while(!mpu.testConnection());
}
void loop() {
// put your main code here, to run repeatedly:
mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
fx = vx = (gx + 300) / 200 + 2;
fy = vy = (gz - 100) / 200 + 2;
fz = vz = (gz - 600) / 200;
output += "data:(";
if (RTC.read(tm)) {
Time = tmYearToCalendar(tm.Year);
Time += '/';
save2digits(&Time, tm.Month);`
Time += '/';
save2digits(&Time, tm.Day);
Time += '/';
save2digits(&Time, tm.Hour);
Time += ':';
save2digits(&Time, tm.Minute);
Time += ':';
save2digits(&Time, tm.Second);
}
acc = String(fx) + '|' +
String(fy) + '|' +
String(fz);
output = "data:(" + Time + '|' + acc + ")";
Serial.println(output);
delay_sec(1);
}