-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathSimpleGyroscope.ino
49 lines (37 loc) · 950 Bytes
/
SimpleGyroscope.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
/*
Arduino LSM6DS3 - Simple Gyroscope
This example reads the gyroscope values from the LSM6DS3
sensor and continuously prints them to the Serial Monitor
or Serial Plotter.
The circuit:
- Arduino Uno WiFi Rev 2 or Arduino Nano 33 IoT
created 10 Jul 2019
by Riccardo Rizzo
This example code is in the public domain.
*/
#include <Arduino_LSM6DS3.h>
void setup() {
Serial.begin(9600);
while (!Serial);
if (!IMU.begin()) {
Serial.println("Failed to initialize IMU!");
while (1);
}
Serial.print("Gyroscope sample rate = ");
Serial.print(IMU.gyroscopeSampleRate());
Serial.println(" Hz");
Serial.println();
Serial.println("Gyroscope in degrees/second");
Serial.println("X\tY\tZ");
}
void loop() {
float x, y, z;
if (IMU.gyroscopeAvailable()) {
IMU.readGyroscope(x, y, z);
Serial.print(x);
Serial.print('\t');
Serial.print(y);
Serial.print('\t');
Serial.println(z);
}
}