-
Notifications
You must be signed in to change notification settings - Fork 48
/
MinimalistExample.ino
81 lines (62 loc) · 2.14 KB
/
MinimalistExample.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
73
74
75
76
77
78
79
80
81
/******************************************************************************
MinimalistExample.ino
Marshall Taylor @ SparkFun Electronics
May 20, 2015
https://github.com/sparkfun/LSM6DS3_Breakout
https://github.com/sparkfun/SparkFun_LSM6DS3_Arduino_Library
Description:
Most basic example of use.
Example using the LSM6DS3 with basic settings. This sketch collects Gyro and
Accelerometer data every second, then presents it on the serial monitor.
Resources:
Uses Wire.h for i2c operation
Uses SPI.h for SPI operation
Either can be omitted if not used
Development environment specifics:
Arduino IDE 1.6.4
Teensy loader 1.23
Hardware connections:
Connect I2C SDA line to A4
Connect I2C SCL line to A5
Connect GND and 3.3v power to the IMU
This code is released under the [MIT License](http://opensource.org/licenses/MIT).
Please review the LICENSE.md file included with this example. If you have any questions
or concerns with licensing, please contact techsupport@sparkfun.com.
Distributed as-is; no warranty is given.
******************************************************************************/
#include "SparkFunLSM6DS3.h"
#include "Wire.h"
#include "SPI.h"
LSM6DS3 myIMU; //Default constructor is I2C, addr 0x6B
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
delay(1000); //relax...
Serial.println("Processor came out of reset.\n");
//Call .begin() to configure the IMU
myIMU.begin();
}
void loop()
{
//Get all parameters
Serial.print("\nAccelerometer:\n");
Serial.print(" X = ");
Serial.println(myIMU.readFloatAccelX(), 4);
Serial.print(" Y = ");
Serial.println(myIMU.readFloatAccelY(), 4);
Serial.print(" Z = ");
Serial.println(myIMU.readFloatAccelZ(), 4);
Serial.print("\nGyroscope:\n");
Serial.print(" X = ");
Serial.println(myIMU.readFloatGyroX(), 4);
Serial.print(" Y = ");
Serial.println(myIMU.readFloatGyroY(), 4);
Serial.print(" Z = ");
Serial.println(myIMU.readFloatGyroZ(), 4);
Serial.print("\nThermometer:\n");
Serial.print(" Degrees C = ");
Serial.println(myIMU.readTempC(), 4);
Serial.print(" Degrees F = ");
Serial.println(myIMU.readTempF(), 4);
delay(1000);
}