Sample code for LSM9DS1 IMU

Dependencies:   mbed LSM9DS1

Files at this revision

API Documentation at this revision

Comitter:
CodyMarquardt
Date:
Thu Nov 07 23:22:46 2019 +0000
Commit message:
This is a sample code for the LSM9DS1 IMU

Changed in this revision

LSM9DS1.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r e068f5847209 LSM9DS1.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LSM9DS1.lib	Thu Nov 07 23:22:46 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/zeutel/code/LSM9DS1/#2ba419ea901e
diff -r 000000000000 -r e068f5847209 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Nov 07 23:22:46 2019 +0000
@@ -0,0 +1,19 @@
+#include "mbed.h"
+#include "LSM9DS1.h"
+
+
+Serial pc(USBTX,USBRX);
+LSM9DS1 imu(p28,p27);
+
+int main(){
+    imu.begin();
+    while(1){
+        imu.readAccel();
+        imu.readGyro();
+        imu.readMag();
+        pc.printf("Accelerometer: x = %8f, y = %8f, z = %8f\n\r",imu.ax,imu.ay, imu.az);
+        pc.printf("Gyro:          x = %f, y = %f, z = %f\n\r",imu.gx,imu.gy, imu.gz);
+        pc.printf("Magnetometer:  x = %f, y = %f, z = %f\n\n\n\r",imu.mx,imu.my, imu.mz);
+        wait(1);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r e068f5847209 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 07 23:22:46 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/a7c7b631e539
\ No newline at end of file