forked from zhanglongqi/ADXL345-for-BBB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Accelerometer_Test.cpp
36 lines (26 loc) · 954 Bytes
/
Accelerometer_Test.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
/*
* Accelerometer_Test.cpp
*
* Created on: Aug 5, 2014
* Author: mahen
*/
#include "ADXL345Accelerometer.h"
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
cout << "Testing ADXL345Accelerometer " << endl;
ADXL345Accelerometer Accelerometer_Test(1, 0x53);
cout<<"Device ID : "<< hex << Accelerometer_Test.getAccelerometer_ID()<<endl;
Accelerometer_Test.SetPowerMode(0x01);
Accelerometer_Test.getAccelerationData();
while (1) {
cout << "X Data :" << dec <<Accelerometer_Test.getAcceleration_X() << " Y Data :" << dec <<Accelerometer_Test.getAcceleration_Y() << " Z Data :" << dec <<Accelerometer_Test.getAcceleration_Z()<<"\t";
cout << "Pitch : " << dec << Accelerometer_Test.getPitch() << "\tRoll : " << dec << Accelerometer_Test.getRoll()<<endl;
usleep(1000000);
Accelerometer_Test.getAccelerationData();
}
cout << "Testing Accelerometer Complete" << endl;
return 0;
}