blob: 0f9aff626fecb20ecbed52a78b1bdee1cd7d9260 (
plain)
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
|
#include <Wire.h>
#include "gyroscope.hpp"
/*
Stops the execution of any more instructions.
*/
void stop()
{
while (1)
;
}
Gyroscope gyroscope;
void setup()
{
Serial.begin(9600);
// Wait for Serial because the Arduino Leonardo is weird
while (!Serial)
;
int gyroscope_id = Gyroscope::initialize();
// Verifiy the gyroscope id
if (gyroscope_id == -1)
{
Serial.println("Error: Failed to communicate with gyroscope component");
stop();
}
gyroscope.setup(gyroscope_id);
Serial.println("Finished setup");
}
void loop()
{
int16_t x, y, z;
gyroscope.readCoordinates(&x, &y, &z);
Serial.print("X: ");
Serial.print((int)x);
Serial.print(" Y: ");
Serial.print((int)y);
Serial.print(" Z: ");
Serial.println((int)z);
delay(1000);
}
|