forked from aliekens/ADXL362
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ADXL362_SimpleRead.cpp
56 lines (41 loc) · 1.54 KB
/
ADXL362_SimpleRead.cpp
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
/*
ADXL362_SimpleRead.cpp - Simple XYZ axis reading example
for Analog Devices ADXL362 - Micropower 3-axis accelerometer
for Spark Core and Spark Internet Button v1.0
go to http://www.analog.com/ADXL362 for datasheet
License: CC BY-SA 3.0: Creative Commons Share-alike 3.0. Feel free
to use and abuse this code however you'd like. If you find it useful
please attribute, and SHARE-ALIKE!
Created June 2012
by Anne Mahaffey - hosted on http://annem.github.com/ADXL362
Modified May 2013
by Jonathan Ruiz de Garibay
Ported to Spark October 2014
by Anthony Liekens
Connect SCLK, MISO, MOSI, and CSB of ADXL362 to
SCLK, MISO, MOSI, and DP 10 of Arduino
(check http://arduino.cc/en/Reference/SPI for details)
*/
#include "InternetButtonADXL362.h"
ADXL362 xl;
int16_t temp;
int16_t XValue, YValue, ZValue, Temperature;
void setup(){
Serial.begin(9600);
xl.begin(A2); // Setup SPI protocol, issue device soft reset
xl.beginMeasure(); // Switch ADXL362 to measure mode
Serial.println("Start Demo: Simple Read");
}
void loop(){
// read all three axis in burst to ensure all measurements correspond to same sample time
xl.readXYZTData(XValue, YValue, ZValue, Temperature);
Serial.print("XVALUE=");
Serial.print(XValue);
Serial.print("\tYVALUE=");
Serial.print(YValue);
Serial.print("\tZVALUE=");
Serial.print(ZValue);
Serial.print("\tTEMPERATURE=");
Serial.println(Temperature);
delay(100); // Arbitrary delay to make serial monitor easier to observe
}