AdvRobot_Team / Mbed 2 deprecated LSM9DS1_Library

Dependencies:   PinDetect mbed

Fork of LSM9DS1_Library by jim hamblen

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "LSM9DS1.h"
00002 #include <vector>
00003 using std::vector;
00004 
00005 DigitalOut myled(LED1);
00006 Serial pc(USBTX, USBRX);
00007 
00008 int main() {
00009     //LSM9DS1 lol(D14, D15, 0x6B, 0x1E);
00010     LSM9DS1 lol(D14, D15, 0xD6, 0x3C);
00011     
00012     vector<float> gyro(3, 0.0);
00013     vector<float> accel(3, 0.0);
00014     
00015     lol.begin();
00016     if (!lol.begin()) {
00017         pc.printf("Failed to communicate with LSM9DS1.\n");
00018     }
00019     lol.calibrate();
00020     
00021     while(1) {
00022         
00023         lol.readGyroFloatVectorDeg(gyro);
00024         lol.readAccelFloatVector(accel);
00025         
00026         
00027         pc.printf("gyro: %.3f %.3f %.3f\n\r", gyro[X_AXIS], gyro[Y_AXIS], gyro[Z_AXIS]);
00028         //pc.printf("accel: %f %f %f\n\n\r", accel[X_AXIS], accel[Y_AXIS], accel[Z_AXIS]);
00029         
00030     }
00031 }